0

What function can I use to create a calculated column [Cumulative Meters] that will sum [Meters] for each row? I can only seem to get a single overall sum for [Meters] using the Totals tool in Settings, which I don't want. I want it to be calculated to use on a long list

Meters Cumulative Meters
0 0
20 20
25 45
10 5
15 70
20 90

1 Answer 1

0

Calculated columns can only reference values in the current item, there is no way to grab data from previous or next rows.

The only ways I can think of to achieve a cumulative result like you're looking for is to either use an Event Receiver or use a workflow.

With the workflow it would have to fire on new item, then pull the cumulative meters value from an item where ID = Current Item:ID - 1. Add that value to the Meters value, then set the new row's Cumulative Meters value. The downside of that approach is that if anyone deletes any rows other than the last row, the calculation will be wrong. And if the last row is deleted, any succeeding rows will be wrong too.

You might be able to use additional workflows to address those two issues, but it may be more work than it's worth.

Depending on what you need the Cumulative Meters data for, it may be better to just calculate that value programatically with javascript anytime you display a list of those values or anytime you view a listitem from that list.

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.