Forum Discussion

kliz's avatar
kliz
Frequent Visitor
2 years ago
Solved

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?

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

     

5 Replies

    • kliz's avatar
      kliz
      Frequent Visitor

      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.

       

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

     

    • kliz's avatar
      kliz
      Frequent Visitor

      Thank you. It worked.

    • kliz's avatar
      kliz
      Frequent Visitor

      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?