In another post, I found this python script that creates a running total. I was able to modify it to do a running product, but I need to have the running product reset when the value of another field changes.
How might I modify this code to do that?
- Calculate the accumulative value of a numeric field.
-
- Expression:
- accumulate(!FieldA!)
-
- Expression Type:
- PYTHON_9.3
-
- Code Block:
- total = 0
- def accumulate(increment):
- global total
- if total:
- total *= increment
- else:
- total = increment
- return total
My data is similar to this
95
The answer would be 1 = 81 and 2 = 25 in the 2nd row of each ID.