Forum Discussion
Help with Running Totals
It looks like you are trying to create a cumulative running total for the 'Commitment Amt' column in the 'Commitment_Docs' table, based on the 'Month Short' and 'FY Order' columns from the 'Month_Vals' table. The issue you're facing is that the current formula is including future months in the cumulative total.
To stop the cumulative total at the current month, you can modify the formula by changing the condition in the FILTER function. Specifically, you want to include only the rows where the 'Month Short' and 'FY Order' values are less than or equal to the maximum values for the same columns. Here's a modified version of your formula:
CALCULATE(
SUM('Commitment_Docs'[Commitment Amt]),
FILTER(
CALCULATETABLE(
SUMMARIZE('Month_Vals', 'Month_Vals'[FY Order], 'Month_Vals'[Month Short]), ALLSELECTED('Month_Vals')
), 'Month_Vals'[FY Order] <= MAX('Month_Vals'[FY Order])
&& 'Month_Vals'[Month Short] <= MAX('Month_Vals'[Month Short]) ) )
In this modified version, I replaced the ISONORAFTER function with a condition that checks if the 'FY Order' and 'Month Short' values are less than or equal to the maximum values for the same columns. This change ensures that only the rows up to and including the current month are considered in the cumulative total.
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.
- Userpath772 years agoHelper II
Thanks 123abc. This is getting close. When I plugged in your changes it was showing the months of Oct, Nov and the last month of Sep. It should only show Oct and Nov. I changed your formula below just removing the <= MAX to = MAX. That change fixed my months where I just see values on Oct and Nov. The problem now is that the values are not showing cumulative, they show the incremental values for Oct and Nov. Is there a solution for this? (My minor changes removing <= show below)
CALCULATE(SUM('Commitment_Docs'[Commitment Amt]),FILTER(CALCULATETABLE(SUMMARIZE('Month_Vals', 'Month_Vals'[FY Order], 'Month_Vals'[Month Short]), ALLSELECTED('Month_Vals')), 'Month_Vals'[FY Order] = MAX('Month_Vals'[FY Order])&& 'Month_Vals'[Month Short] = MAX('Month_Vals'[Month Short]) ) )