I have used the label expression 'Label a related table' (one-to many) and it works just fine, but I would like to go one step further and 'count' repited values in the resulted label.
I just can't seem to figure out how to write it with python...
def FindLabel ([keyField], [FirstLabel]):
import arcpy
key1 = [keyField] # Key field in feature class
key2 = "ID" # Key field in related table
L = [FirstLabel] # Label field in feature class
L2 = "Label2" # Label field in related table
myDataTable = r"<path-to-related-table>" # Path to related table
cur = arcpy.da.SearchCursor(myDataTable, [key2, L2])
for row in cur:
if str(key1) == str(row[0]):
L = L + " " + str(row[1])
return LSo the idea is to count row[1], for expample if there is 4 relations where the resulted label is "red red red green", I would like to show: "3 red, 1 green" .
Is this possible?