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
Zahin
Frequent Visitor

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:

Zahin_0-1678883579680.png

 

Now if I want to see the cumulative sum for May to September, it should be something like this:

Zahin_1-1678883628274.png

 

How can I achieve this? Thank you

1 ACCEPTED SOLUTION
v-rongtiep-msft
Community Support
Community Support

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 ()
    )

vpollymsft_1-1679378539084.png

 

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 _ Polly

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-rongtiep-msft
Community Support
Community Support

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 ()
    )

vpollymsft_1-1679378539084.png

 

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 _ Polly

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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

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.