<?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>idea Calculate Field using sequential numbers, partition by GROUP_ID field, order by VALUES field in ArcGIS Pro Ideas</title>
    <link>https://community.esri.com/t5/arcgis-pro-ideas/calculate-field-using-sequential-numbers-partition/idi-p/1526000</link>
    <description>&lt;P&gt;ArcGIS Pro 3.3.1; file geodatabase&lt;/P&gt;
&lt;P&gt;I want to use the field calculator to populate a new/blank field called ROW_NUM.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;For each group, using sequential numbers starting at 1, ordered by the VALUES field (descending)…populate the ROW_NUM field.&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE&gt;GROUP_ID VALUES&lt;FONT color="#0000FF"&gt; &lt;STRONG&gt;ROW_NUM&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;1        0      2&lt;BR /&gt;1        1      1&lt;BR /&gt;1        0      3&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;2        0      1&lt;BR /&gt;2        0      2&lt;BR /&gt;&lt;BR /&gt;3        1      1&lt;BR /&gt;3        0      3&lt;BR /&gt;3        1      2&lt;/PRE&gt;
&lt;P&gt;It is my understanding that can’t currently be done using the Calculate Field tool (Python). Could that functionality be added?&lt;/P&gt;
&lt;P&gt;If it were an Oracle SQL query, it would look like this:&lt;/P&gt;
&lt;PRE&gt;select&lt;BR /&gt;    GROUP_ID,&lt;BR /&gt;    VALUES,&lt;BR /&gt;    row_number() over (partition by GROUP_ID order by VALUES desc) as rn&lt;BR /&gt;from&lt;BR /&gt;    MY_TABLE&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 27 Sep 2024 22:34:51 GMT</pubDate>
    <dc:creator>Bud</dc:creator>
    <dc:date>2024-09-27T22:34:51Z</dc:date>
    <item>
      <title>Calculate Field using sequential numbers, partition by GROUP_ID field, order by VALUES field</title>
      <link>https://community.esri.com/t5/arcgis-pro-ideas/calculate-field-using-sequential-numbers-partition/idi-p/1526000</link>
      <description>&lt;P&gt;ArcGIS Pro 3.3.1; file geodatabase&lt;/P&gt;
&lt;P&gt;I want to use the field calculator to populate a new/blank field called ROW_NUM.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;For each group, using sequential numbers starting at 1, ordered by the VALUES field (descending)…populate the ROW_NUM field.&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE&gt;GROUP_ID VALUES&lt;FONT color="#0000FF"&gt; &lt;STRONG&gt;ROW_NUM&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;1        0      2&lt;BR /&gt;1        1      1&lt;BR /&gt;1        0      3&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;2        0      1&lt;BR /&gt;2        0      2&lt;BR /&gt;&lt;BR /&gt;3        1      1&lt;BR /&gt;3        0      3&lt;BR /&gt;3        1      2&lt;/PRE&gt;
&lt;P&gt;It is my understanding that can’t currently be done using the Calculate Field tool (Python). Could that functionality be added?&lt;/P&gt;
&lt;P&gt;If it were an Oracle SQL query, it would look like this:&lt;/P&gt;
&lt;PRE&gt;select&lt;BR /&gt;    GROUP_ID,&lt;BR /&gt;    VALUES,&lt;BR /&gt;    row_number() over (partition by GROUP_ID order by VALUES desc) as rn&lt;BR /&gt;from&lt;BR /&gt;    MY_TABLE&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2024 22:34:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-ideas/calculate-field-using-sequential-numbers-partition/idi-p/1526000</guid>
      <dc:creator>Bud</dc:creator>
      <dc:date>2024-09-27T22:34:51Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field with sequential numbers, partition by GROUP_ID field, order by VALUES field</title>
      <link>https://community.esri.com/t5/arcgis-pro-ideas/calculate-field-using-sequential-numbers-partition/idc-p/1526013#M31701</link>
      <description>&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-pro-ideas/row-number-function-in-fgdb-sql/idc-p/1526011#M31700" target="_self"&gt;ROW_NUMBER function in FGDB SQL&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2024 18:13:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-ideas/calculate-field-using-sequential-numbers-partition/idc-p/1526013#M31701</guid>
      <dc:creator>Bud</dc:creator>
      <dc:date>2024-08-22T18:13:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field using sequential numbers, partition by GROUP_ID field, order by VALUES field</title>
      <link>https://community.esri.com/t5/arcgis-pro-ideas/calculate-field-using-sequential-numbers-partition/idc-p/1526054#M31703</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/351335"&gt;@Bud&lt;/a&gt;&amp;nbsp;What do you think about using this altered Sequential number?&lt;BR /&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/calculate-field.htm" target="_blank"&gt;Calculate Field (Data Management)—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Calculates a sequential number
# More calculator examples at esriurl.com/CalculatorExamples
rec={}
def SequentialNumberByGroup(group):
global rec
pStart = 1
pInterval = 1
if group in rec:
rec[group] = rec[group] + pInterval
else:
rec[group] = pStart
return rec[group]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2024 18:41:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-ideas/calculate-field-using-sequential-numbers-partition/idc-p/1526054#M31703</guid>
      <dc:creator>JonathanNeal</dc:creator>
      <dc:date>2024-08-22T18:41:55Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field using sequential numbers, partition by GROUP_ID field, order by VALUES field</title>
      <link>https://community.esri.com/t5/arcgis-pro-ideas/calculate-field-using-sequential-numbers-partition/idc-p/1526236#M31716</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/342593"&gt;@JonathanNeal&lt;/a&gt;&amp;nbsp;Thanks. At first glance, that script doesn't seem to&amp;nbsp;&lt;SPAN&gt;order the sequential numbers by the VALUES field (descending), which is a requirement.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Aug 2024 01:42:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-ideas/calculate-field-using-sequential-numbers-partition/idc-p/1526236#M31716</guid>
      <dc:creator>Bud</dc:creator>
      <dc:date>2024-08-23T01:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field using sequential numbers, partition by GROUP_ID field, order by VALUES field</title>
      <link>https://community.esri.com/t5/arcgis-pro-ideas/calculate-field-using-sequential-numbers-partition/idc-p/1526569#M31730</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/351335"&gt;@Bud&lt;/a&gt;&amp;nbsp;If sorting is a requirement, then the Sort tool will need to be ran first.&amp;nbsp; Interesting idea though, to force processing order with the Calculate Field tool.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Aug 2024 17:13:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-ideas/calculate-field-using-sequential-numbers-partition/idc-p/1526569#M31730</guid>
      <dc:creator>JonathanNeal</dc:creator>
      <dc:date>2024-08-23T17:13:03Z</dc:date>
    </item>
  </channel>
</rss>

