Forum Discussion
Calculate cumulative sum for a selected date
Hello,
I want to calculate cumulative sum for a specific date range. It should also have the total sum until the start date.
Example table:
Now if I want to see the cumulative sum for May to September, it should be something like this:
How can I achieve this? Thank you
- Anonymous3 years ago
Hi Zahin ,
I have created a simple sample, please refer to my pbix file to see if it helps you.
Create a meausre.
Measure = VAR _max = MAXX ( ALLSELECTED ( 'Table 2' ), 'Table 2'[Date] ) VAR _min = MINX ( ALLSELECTED ( 'Table 2' ), 'Table 2'[Date] ) VAR _re = CALCULATE ( SUM ( 'Table'[amount] ), FILTER ( ALL ( 'Table' ), 'Table'[Month] <= MAX ( 'Table'[Month] ) ) ) RETURN IF ( MAX ( 'Table'[Month] ) >= _min && MAX ( 'Table'[Month] ) <= _max, _re, BLANK () )How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ PollyIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 Replies
- AnonymousNot applicable
Hi Zahin ,
I have created a simple sample, please refer to my pbix file to see if it helps you.
Create a meausre.
Measure = VAR _max = MAXX ( ALLSELECTED ( 'Table 2' ), 'Table 2'[Date] ) VAR _min = MINX ( ALLSELECTED ( 'Table 2' ), 'Table 2'[Date] ) VAR _re = CALCULATE ( SUM ( 'Table'[amount] ), FILTER ( ALL ( 'Table' ), 'Table'[Month] <= MAX ( 'Table'[Month] ) ) ) RETURN IF ( MAX ( 'Table'[Month] ) >= _min && MAX ( 'Table'[Month] ) <= _max, _re, BLANK () )How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ PollyIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- amitchandak
Super User
Zahin , you need measure like
values For beginning
Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(all('Date'),'Date'[date] <=max('Date'[date])))
Only for selected range
Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(allselected(date),date[date] <=max(date[Date])))
Same you can do with window function
Power BI Window function Rolling, Cumulative/Running Total, WTD, MTD, QTD, YTD, FYTD: https://youtu.be/nxc_IWl-tTc
Running Total/ Cumulative: https://www.youtube.com/watch?v=h2wsO332LUo&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=41