<?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: How can I calculate a &amp;quot;moving&amp;quot; conditional evaluation in Field Calculator? in Implementing ArcGIS Questions</title>
    <link>https://community.esri.com/t5/implementing-arcgis-questions/how-can-i-calculate-a-quot-moving-quot-conditional/m-p/446356#M398</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The following should work in Pro, not sure about ArcMap since it uses Python 2.x.&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Code Block:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; collections &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; defaultdict

&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;counter_gen&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    counter &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; defaultdict&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;int&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    v &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; None
    &lt;SPAN class="keyword token"&gt;while&lt;/SPAN&gt; &lt;SPAN class="token boolean"&gt;True&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        counter&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;v&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;
        v &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;yield&lt;/SPAN&gt; counter&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;v&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; v &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt; None
        
g &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; counter_gen&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
next&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;g&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&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;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&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;and Expression:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;g&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;send&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;!ID!&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&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;&lt;/P&gt;&lt;P&gt;The code above works whether the table is sorted by ID groups or not.&amp;nbsp; If the table is sorted by some other column, the code just takes the first ID value x and makes it 1, the second ID value x as 2, etc.... as it finds them.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 19:56:51 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2021-12-11T19:56:51Z</dc:date>
    <item>
      <title>How can I calculate a "moving" conditional evaluation in Field Calculator?</title>
      <link>https://community.esri.com/t5/implementing-arcgis-questions/how-can-i-calculate-a-quot-moving-quot-conditional/m-p/446354#M396</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was wondering if anyone has ever tried doing this kind of calculation in field calculator, or if it is even possible. What I am trying to do is to calculate an order field, based on repeating polyline IDs. In excel I would do something like "If ID2 = ID1, Order1 + 1, else 1. In essence, the query refers to another column and to itself, and it refers to specific rows, sometimes other than the row being calculated. Is this doable with a VB or Python script?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/441821_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Apr 2019 09:20:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/implementing-arcgis-questions/how-can-i-calculate-a-quot-moving-quot-conditional/m-p/446354#M396</guid>
      <dc:creator>Stefande_Bruin1</dc:creator>
      <dc:date>2019-04-11T09:20:02Z</dc:date>
    </item>
    <item>
      <title>Re: How can I calculate a "moving" conditional evaluation in Field Calculator?</title>
      <link>https://community.esri.com/t5/implementing-arcgis-questions/how-can-i-calculate-a-quot-moving-quot-conditional/m-p/446355#M397</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sort of, but for text fields.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image" height="418" src="https://community.esri.com/legacyfs/online/441825_sequence05.png" width="278" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.arcgis.com/home/item.html?id=90d9ca933e8c4b96bf341a20ae1f2514"&gt;Table Tools for Pro&lt;/A&gt;&amp;nbsp; on the Code Sharing site.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are a number of tools there.&amp;nbsp; Some are documented in a blog I wrote&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/blogs/dan_patterson/2018/02/12/table-tools-a-set-of-tools-for-working-with-tabular-data"&gt;/blogs/dan_patterson/2018/02/12/table-tools-a-set-of-tools-for-working-with-tabular-data&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are code adept, you could modify to your specific needs, the above example was used for object subclassing and sequencing&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Apr 2019 13:53:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/implementing-arcgis-questions/how-can-i-calculate-a-quot-moving-quot-conditional/m-p/446355#M397</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2019-04-11T13:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: How can I calculate a "moving" conditional evaluation in Field Calculator?</title>
      <link>https://community.esri.com/t5/implementing-arcgis-questions/how-can-i-calculate-a-quot-moving-quot-conditional/m-p/446356#M398</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The following should work in Pro, not sure about ArcMap since it uses Python 2.x.&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Code Block:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; collections &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; defaultdict

&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;counter_gen&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    counter &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; defaultdict&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;int&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    v &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; None
    &lt;SPAN class="keyword token"&gt;while&lt;/SPAN&gt; &lt;SPAN class="token boolean"&gt;True&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        counter&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;v&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;
        v &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;yield&lt;/SPAN&gt; counter&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;v&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; v &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt; None
        
g &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; counter_gen&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
next&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;g&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&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;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&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;and Expression:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;g&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;send&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;!ID!&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&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;&lt;/P&gt;&lt;P&gt;The code above works whether the table is sorted by ID groups or not.&amp;nbsp; If the table is sorted by some other column, the code just takes the first ID value x and makes it 1, the second ID value x as 2, etc.... as it finds them.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:56:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/implementing-arcgis-questions/how-can-i-calculate-a-quot-moving-quot-conditional/m-p/446356#M398</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-11T19:56:51Z</dc:date>
    </item>
  </channel>
</rss>

