Hi All.. So here is what I'm trying to do. I know how to calculate Unique ID's. What I'm trying to do is calculate them based the the sort of the table. My data was randomly selected and on this field the table has been sorted. I want to then calculate the Unique ID's based on this sort. So my first record will get a 1 and so on. What currently happens is the unique ID is created based on the object ID or FID not sure which causing my sort on my field to be invalid. Is there a way to force the Unique ID to calculate based on the table sort? Thanks
-Jeremy
Solved! Go to Solution.
rank fields in
https://community.esri.com/docs/DOC-14928-free-tools-for-arcgis-pro-table-tools
See if this approach works for you. In the example below, I use the arcpy.da.UpdateCursor with a sql clause to ORDER By (sort) by PARCEL which is a text field:
import arcpy
fc = r'C:\Temp\Junk.gdb\points'
id = 0
with arcpy.da.UpdateCursor(fc,'SortID', sql_clause=(None, 'ORDER BY PARCEL')) as cursor:
for row in cursor:
id+=1
row[0] = id
cursor.updateRow(row)
Here is a screen capture of my results:
Thanks for the reply Joe!
rank fields in
https://community.esri.com/docs/DOC-14928-free-tools-for-arcgis-pro-table-tools
Thanks Dan I was able to use your tools and do what I needed to do.
Just out of courtesy, how about you mark Dan's reply as the answer.
Because I actually used his. I Yours most likely works as well I just don't have experience with coding and modifying it. If I could mark them both as correct I would have.
That's cool! Dan Patterson needs the MVP points more than I do...
actually... it is the "new Dan". My old account got "retired and frozen" and I had to open a new one. At level 5 now , only 140,000 to go till I am back where I was
You are telling me I have more points than you now! That just made my day!!!