Problem with Sequential Counter

322
1
08-12-2021 07:00 AM
MichaelKlassen
New Contributor

Hello All, 

 

Using the following sequential counter built in to the field calculator using Python 3. Really missing this functionality because it was  a simple calculation in ArcMap that would sequentially add a number as the field was sorted within the table. It appears that the built in function will only do this by the Object ID and ignores any sorting you have applied. Is there anyway to sequentially add a number based upon sorting instead of the underlying data?

 

Thanks in advance, 

 

Mike

 

# Calculates a sequential number
# More calculator examples at esriurl.com/CalculatorExamples
rec=0
def SequentialNumber():
global rec
pStart = 1
pInterval = 1
if (rec == 0):
rec = pStart
else:
rec = rec + pInterval
return rec

 

MichaelKlassen_0-1628776566818.png

 

Tags (1)
0 Kudos
1 Reply
JoshuaBixby
MVP Esteemed Contributor

Are you up for using an update cursor, or do you have to do it within Field Calculator?

0 Kudos