cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Need a help - Calculate the running total in item level month over month

Hey all,

 

I know how to do cumulative calculation when putting date in row. But this time, i need to calculate the running total in item level (row) month over month (column) 

 

See below example. the 2020-08 cumulative demands should be 44 for product A. Considering the 2020-09 demands is 103, so the cumulative demands by the end of 2020-09 should be 147...

 

 

This is my dax, but it's not correct 😞 Would you let me know your thoughts? Thanks!

Cumulative Demands = CALCULATE(CALCULATE([Demands],FILTER(ALLSELECTED('Date'[Date]),'Date'[Date]<=MAX('Date'[Date]))),FILTER(ALL('Fact'),COUNTROWS(FILTER('Fact',EARLIER('Fact'[Item])='Fact'[Item] && EARLIER('Fact'[Date])='Fact'[Date]))))

 

naoyixue1_0-1600832856245.png

 

1 ACCEPTED SOLUTION
Super User IV
Super User IV

@naoyixue1 , Try like

 

Cumulative Demands = CALCULATE([Demands],FILTER(ALL('Fact'),COUNTROWS(FILTER('Fact',Max('Fact'[Item])='Fact'[Item] && MAX('Fact'[Date])='Fact'[Date]))))

or

 

Cumulative Demands =CALCULATE([Demands],FILTER(ALLSELECTED('Date'[Date]),'Date'[Date]<=MAX('Date'[Date])),FILTER(ALL('Fact'),COUNTROWS(FILTER('Fact',Max('Fact'[Item])='Fact'[Item] ))))

 

 



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

View solution in original post

2 REPLIES 2
Super User IV
Super User IV

@naoyixue1 , Try like

 

Cumulative Demands = CALCULATE([Demands],FILTER(ALL('Fact'),COUNTROWS(FILTER('Fact',Max('Fact'[Item])='Fact'[Item] && MAX('Fact'[Date])='Fact'[Date]))))

or

 

Cumulative Demands =CALCULATE([Demands],FILTER(ALLSELECTED('Date'[Date]),'Date'[Date]<=MAX('Date'[Date])),FILTER(ALL('Fact'),COUNTROWS(FILTER('Fact',Max('Fact'[Item])='Fact'[Item] ))))

 

 



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

View solution in original post

Thanks @amitchandak Both ways work. Really appreciate your effort. 

Helpful resources

Announcements
secondImage

Happy New Year from Power BI

This is a must watch for a message from Power BI!

December Update

Check it Out!

Click here to read more about the December 2020 Updates!

Community Blog

Check it Out!

Click here to read the latest blog and learn more about contributing to the Power BI blog!

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Top Solution Authors
Top Kudoed Authors