Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello to all,
I'm looking for the formula to calculate the cumulative sum in a table with 3 dimensions.
For clarity I attach an example of the results that I would get.
Thanks to everyone who can help me.
Year | Month | Agent | Sum(Amount) | ? |
2012 | 1 | A | 100 | 100 |
2012 | 1 | B | 80 | 80 |
2012 | 2 | A | 100 | 200 |
2012 | 2 | B | 80 | 160 |
2012 | 3 | A | 100 | 300 |
2012 | 3 | B | 80 | 240 |
2012 | 4 | A | 100 | 400 |
2012 | 4 | B | 80 | 320 |
2012 | 5 | A | 100 | 500 |
2012 | 5 | B | 80 | 400 |
2012 | 6 | A | 100 | 600 |
2012 | 6 | B | 80 | 480 |
2012 | 7 | A | 100 | 700 |
2012 | 7 | B | 80 | 560 |
2012 | 8 | A | 100 | 800 |
2012 | 8 | B | 80 | 640 |
2012 | 9 | A | 100 | 900 |
2012 | 9 | B | 80 | 720 |
2012 | 10 | A | 100 | 1000 |
2012 | 10 | B | 80 | 800 |
2012 | 11 | A | 100 | 1100 |
2012 | 11 | B | 80 | 880 |
2012 | 12 | A | 100 | 1200 |
2012 | 12 | B | 80 | 960 |
Maybe not the prettiest expression, but you could try this:
If(Agent='A', RangeSum(Above(TOTAL Sum({$<Agent*={A}>}Amount), 0, RowNo(TOTAL)))
,If(Agent='B', RangeSum(Above(TOTAL Sum({$<Agent*={B}>}Amount), 0, RowNo(TOTAL)))))
Thank you Anton, your response functions in this specific case, but I'd like to find a more generic formula, something that works regardless of the number of elements in the third dimension.
Also I would like the values come back to zero when the year changes.
Here below is the table that results from your formula.
Year | Month | Agent | If(Agent='A', RangeSum(Above(TOTAL Sum({$<Agent*={A}>}Amount), 0, RowNo(TOTAL))) ,If(Agent='B', RangeSum(Above(TOTAL Sum({$<Agent*={B}>}Amount), 0, RowNo(TOTAL))))) |
2012 | 1 | A | 100 |
2012 | 1 | B | 80 |
2012 | 2 | A | 200 |
2012 | 2 | B | 160 |
2012 | 3 | A | 300 |
2012 | 3 | B | 240 |
2012 | 4 | A | 400 |
2012 | 4 | B | 320 |
2012 | 5 | A | 500 |
2012 | 5 | B | 400 |
2012 | 6 | A | 600 |
2012 | 6 | B | 480 |
2012 | 7 | A | 700 |
2012 | 7 | B | 560 |
2012 | 8 | A | 800 |
2012 | 8 | B | 640 |
2012 | 9 | A | 900 |
2012 | 9 | B | 720 |
2012 | 10 | A | 1000 |
2012 | 10 | B | 800 |
2012 | 11 | A | 1100 |
2012 | 11 | B | 880 |
2012 | 12 | A | 1200 |
2012 | 12 | B | 960 |
2013 | 1 | A | 1270 |
2013 | 1 | B | 1070 |
2013 | 2 | A | 1340 |
2013 | 2 | B | 1180 |
2013 | 3 | A | 1410 |
2013 | 3 | B | 1290 |
2013 | 4 | A | 1480 |
2013 | 4 | B | 1400 |
2013 | 5 | A | 1550 |
2013 | 5 | B | 1510 |
2013 | 6 | A | 1620 |
2013 | 6 | B | 1620 |
2013 | 7 | A | 1690 |
2013 | 7 | B | 1730 |
2013 | 8 | A | 1760 |
2013 | 8 | B | 1840 |
2013 | 9 | A | 1830 |
2013 | 9 | B | 1950 |
2013 | 10 | A | 1900 |
2013 | 10 | B | 2060 |
2013 | 11 | A | 1970 |
2013 | 11 | B | 2170 |
2013 | 12 | A | 2040 |
2013 | 12 | B | 2280 |