AnsweredAssumed Answered

Increment Field in Sorted Table

Question asked by jborgion Champion on Oct 30, 2017
Latest reply on Jul 19, 2019 by MatthewDuffy

I've seen a few posts here and on stack exchange that mention this topic, but when I use the code provided it fails. This seems pretty straight forward:


counter = 1
while counter < 11:
  print (counter)
  counter += 1

 and when in an idle window, returns :






 As expected.  However, if I put something like that in the field calculator, I get 000539 Error.  It seems that any auto-incrementer I've found online has a dependency on the OID in way or another.  I've tried a da.UpdateCursor, and CalculateField_managment:  


with no luck.


Is it possible to sort a table, and then calculate the position each record has in the sort?