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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
kliz
Regular Visitor

Cumulative Sum

Hello,
I am a beginner in powerbi and I want to compute the cumulative sum for each day, which includes the current day's sale amount and the cumulative sum of the previous day's sales. 
For example, let's say we have a table with columns for 'Date' and 'Amount':
Date                                                Amount
2024-04-01                                   100
2024-04-02                                   150
2024-04-03                                   200 
2024-04-04                                   120
The cumulative sum for each day would be:
For 2024-04-01: 100
For 2024-04-02: 100 (from 2024-04-01) + 150 = 250
For 2024-04-03: 250 (from 2024-04-02) + 200 = 450
For 2024-04-04: 450 (from 2024-04-03) + 120 = 570

How can i do that?

1 ACCEPTED SOLUTION
Tahreem24
Super User
Super User

@kliz YOu can try this measure, I took your example and generated the expected result.

 

Cumulative = CALCULATE(SUM(TabA[Value]),FILTER(ALL(TabA),TabA[Date]<=MAX('TabA'[Date])))
 
Tahreem24_0-1714409705415.png

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

View solution in original post

5 REPLIES 5
Tahreem24
Super User
Super User

@kliz YOu can try this measure, I took your example and generated the expected result.

 

Cumulative = CALCULATE(SUM(TabA[Value]),FILTER(ALL(TabA),TabA[Date]<=MAX('TabA'[Date])))
 
Tahreem24_0-1714409705415.png

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

what if for some days there is no values, how can i make it so that it reproduces the previous value to the current and so on till if finds the next currentday value?Capture d’écran 2024-04-30 133058.png

 

Thank you. It worked.

Greg_Deckler
Super User
Super User

@kliz Better Running Total - Microsoft Fabric Community


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thank you for your input. I watched your video and I'll keep that in mind. I tried to apply it to my data but i did not get the expected result is there something i should add?As you can see it brings the same values for the different type.As you can see it brings the same values for the different type.

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

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