<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Why is my Arcade expression only interpreted once unless I include an attribute value? in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/why-is-my-arcade-expression-only-interpreted-once/m-p/666977#M29600</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can't say for sure why it doesn't work in Pro 2.2 (I think lack of cursor support), but when I set this up in Pro 2.3 (beta), I see this:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/432353_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;Hit Run again:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/432354_pastedImage_2.png" /&gt;&lt;/P&gt;&lt;P&gt;And again, just for good measure&amp;nbsp;&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-3 jive-image" src="https://community.esri.com/legacyfs/online/432355_pastedImage_15.png" /&gt;&lt;/P&gt;&lt;P&gt;I don't think cursors are supported using Arcade until Pro 2.3.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 28 Dec 2018 19:38:05 GMT</pubDate>
    <dc:creator>KoryKramer</dc:creator>
    <dc:date>2018-12-28T19:38:05Z</dc:date>
    <item>
      <title>Why is my Arcade expression only interpreted once unless I include an attribute value?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/why-is-my-arcade-expression-only-interpreted-once/m-p/666976#M29599</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am using the Calculate Field tool generate a random number between 0 and 180. I can do this with a Python codeblock. The following gives me a different random integer in each row:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;def randomize():
&amp;nbsp;&amp;nbsp;&amp;nbsp; import random
&amp;nbsp;&amp;nbsp;&amp;nbsp; return random.randint(0,180)‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I thought I could do it with an Arcade expression:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;Round(Random() * 180, 0)‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, this gave me only one random number: each row had the same value, which isn't what I wanted. Apparently, the Arcade expression was calculated only once and its result was copied.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found an awkward workaround, by including the OBJECTID in the expression:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;($feature.OBJECTID * 0) + Round(Random() * 180, 0)‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This, just like the Python codeblock, gave me different random numbers in each row. However, the Python codeblock didn't require me to specify a "dummy" value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #3d3d3d; font-family: Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px; word-wrap: break-word;"&gt;(Side note: including the attribute value didn't run significantly more slowly, even though there are thousands of rows in this feature class.)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Is it "as expected" behavior that an Arcade expression will only be interpreted once unless an attribute is included in the expression?&lt;/STRONG&gt; It wasn't intuitively obvious to me.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:11:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/why-is-my-arcade-expression-only-interpreted-once/m-p/666976#M29599</guid>
      <dc:creator>EricaPfister</dc:creator>
      <dc:date>2021-12-12T04:11:42Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my Arcade expression only interpreted once unless I include an attribute value?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/why-is-my-arcade-expression-only-interpreted-once/m-p/666977#M29600</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can't say for sure why it doesn't work in Pro 2.2 (I think lack of cursor support), but when I set this up in Pro 2.3 (beta), I see this:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/432353_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;Hit Run again:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/432354_pastedImage_2.png" /&gt;&lt;/P&gt;&lt;P&gt;And again, just for good measure&amp;nbsp;&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-3 jive-image" src="https://community.esri.com/legacyfs/online/432355_pastedImage_15.png" /&gt;&lt;/P&gt;&lt;P&gt;I don't think cursors are supported using Arcade until Pro 2.3.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Dec 2018 19:38:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/why-is-my-arcade-expression-only-interpreted-once/m-p/666977#M29600</guid>
      <dc:creator>KoryKramer</dc:creator>
      <dc:date>2018-12-28T19:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my Arcade expression only interpreted once unless I include an attribute value?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/why-is-my-arcade-expression-only-interpreted-once/m-p/666978#M29601</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Gotcha -- I'm in Pro 2.1.3, so this is definitely not expected behavior but it will be addressed whenever we're able to upgrade our Pro version. Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Dec 2018 19:41:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/why-is-my-arcade-expression-only-interpreted-once/m-p/666978#M29601</guid>
      <dc:creator>EricaPfister</dc:creator>
      <dc:date>2018-12-28T19:41:40Z</dc:date>
    </item>
  </channel>
</rss>

