I am using ArcGIS Pro 2.3. I have a point layer, for which I need to calculate a unique increasing number. I am trying to calculate a field "BlockUnique" with a sequential number sequence (1, 2, 3, and so on). I have another field "BlockID". I need the BlockUnique field to calculate the increasing number sequence and restart for every unique BlockID. An example below.

Is this able to be done without Python?

If python is required, how would I script this?

I am not even sure where to begin!

Example: BlockID on left, BlockUnique on right.

A 1
A 2
A 3
B 1
B 2
C 1
D 1
D 2

2 Answers 2


If we frame it another way, you basically want BlockUnique to be the number of occurrences of BlockID seen up to the current row.

Code block:

from collections import defaultdict

lookup = defaultdict(int)

def get_id(value):
    lookup[value] += 1
    return lookup[value]


  • I love defaultdict but I really dislike global. Fortunately in this case global isn't needed because Python dictionaries are mutable so they are passed by reference, which makes the global/local namespace issue moot when updating contents of the variable.
    – bixb0012
    Commented Apr 16, 2022 at 16:04
  • Good call, edited.
    – mikewatt
    Commented Apr 16, 2022 at 23:42

This is a variation to mikewatt's answer and uses the same logic suggested by FelixIP's link.

Code block

lookup = {}
def get_id(value):
   lookup[value] = lookup.get(value, 0) + 1
   return lookup[value]



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.