Hello community, I need help working with the attribute table, I need to number all the lines in my case from 1 to 357, but one of the columns with the name of the properties has to be in alphabetical order, how can I do this using the field calculator.
Thanks in advance for your attention
Switch language to Arcade, use this expression (change "TextField1" to the name of your field):
var oid = $feature.OBJECTID
var txt = $feature.TextField1
var previous = Filter($featureset, "TextField1 < @txt")
var same_lower = Filter($featureset, "TextField1 = @txt AND OBJECTID < @oid")
return Count(previous) + Count(same_lower) + 1
Thanks for the quick reply, I'm relatively new to working with Arqgis, how do I change the Field Calculator language to arcade?
But this is for ArcGIS Pro, and I didn't realize that you posted this question in the ArcMap group.
If you're working with ArcMap, it's much easier to do this task with a little Python script.
Open your Python Window
Paste in this script, edit the first three lines and execute (hit Enter).
table = "TestPolygons" # the table path or layer name
text_field = "TextField1" # the sort field
number_field = "IntegerField1" # the field that will be calculated
i = 1
with arcpy.da.UpdateCursor(table, [text_field, number_field], sql_clause=[None, "ORDER BY {}".format(text_field)]) as cursor:
for row in cursor:
row[1] = i
cursor.updateRow(row)
i += 1