Populate a Field with consecutive numbers in Field Calculator

4459
2
07-27-2017 09:53 AM
CommonUser
New Contributor II

How do you populate a Field with consecutive numbers in the field calculator ?

0 Kudos
2 Replies
BrianCarson2
Esri Contributor

Hello Randy,

The following Field Calculator expression (which must be used with the Python Parser), will auto increment a numeric field. We can modify the pStart = 1 and pInterval = 1 parameters to control the starting number as well as how much it will increment by.

Pre-Logic Script Code:

global rec
rec=0
def autoIncrement():
  global rec
  pStart = 1
  pInterval = 1
  if (rec == 0):
    rec = pStart  
  else:
    rec += pInterval
  return rec

<FieldName> =

autoIncrement()

Best,


Brian

CommonUser
New Contributor II

Awesome!! Thanks

Thank You,

Randy Hill

GIS Analyst II

City Of Newnan

25 Lagrange St.

Newnan, Georgia 30263

(678)673-5503

0 Kudos