I am trying to calculate a field that marks duplicates and sequentially numbers them. I am using the code below that I found here: Generating sequential numbering for duplicate values in a field sorted by ObjectID.
It works, but I get a duplicate starting value before it begins sequentially numbering unless I only run the field calculator on the selected values. When I calculate after manually selecting the duplicate rows and running it on only those values, it works fine.
Here's the code:
prevFieldValue = ''
counter = 0
if myFieldValue == prevFieldValue:
counter += 1
counter = 1
prevFieldValue = myFieldValue
Results running it on all roads (nothing selected):
Results running it after manually selecting the duplicated fields (not too efficient!).