3

In ArcMap 10.2, I wish to create a field which contains the cumulative values of another field in the same attribute table. For example, if the first three cells of the original field contained the values 1, 2, and 3, I would like my new field to contain the corresponding values of 1, 3, and 6. I have seen some solutions to this issue, but as I am not adept in coding I was unable to follow.

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
jc22
  • 425
  • 7
  • 15

1 Answers1

4

You need a codeblock in your field calculator. The example below is with a Python parser

total = 0
def cumsum(inc):
 global total
 total+=inc
 return total

The first line initialize a variable to 0, then you define a function called cumsum with one argument.

for the incrementation, you want your variable to be "global" that will keep incrementing the value.

To call this code block, use

cumsum(!field_name!)
radouxju
  • 49,636
  • 2
  • 71
  • 144