Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
naoyixue1
Post Patron
Post Patron

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
amitchandak
Super User
Super User

@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] ))))

 

 

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@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] ))))

 

 

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.