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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
46Days
New Member

Error when using cumulative sum with activated filters

I found a solution to my problem but I don't know why the cumulative sum is not working.

 

I have the following table which brings me some data which I want to add cumulatively, the question is that when filtering is not applying the cumulative sum function.

 

46Days_0-1676303394412.png

 

46Days_1-1676303418555.png

following the above logic, the table with the filter enabled should look like this

46Days_0-1676308343282.png

 

The function I found and am using is the following

Cumulative_Revenue = CALCULATE(SUM('Hoja1 (2)'[Value]), FILTER(ALLSELECTED('Hoja1 (2)'[# Month]), YEAR('Hoja1 (2)'[# Month])=YEAR(MAX('Hoja1 (2)'[# Month]))&&'Hoja1 (2)'[# Month] <= MAX('Hoja1 (2)'[# Month])))

 

I would appreciate if you can help me to find the error why it is not adding correctly cumulatively with the filter activated.

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @46Days 

 

You can try the following methods.

Measure =
VAR _Cumulative1 = CALCULATE ( SUM ( 'Table'[Value] ),
        FILTER ( ALL ( 'Table' ),
            [# Month] <= SELECTEDVALUE ( 'Table'[# Month] )
                && [Service] = SELECTEDVALUE ( 'Table'[Service] ) ) )
VAR _Cumulative2 = CALCULATE ( SUM ( 'Table'[Value] ),
        FILTER ( ALL ( 'Table' ),
            [# Month] = SELECTEDVALUE ( 'Table'[# Month] )
                && [Service] <= SELECTEDVALUE ( 'Table'[Service] ) ) )
RETURN
    IF ( ISFILTERED ( 'Table'[Month] ), _Cumulative2, _Cumulative1 )

vzhangti_0-1676356288660.png

vzhangti_1-1676356319357.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

1 REPLY 1
v-zhangti
Community Support
Community Support

Hi, @46Days 

 

You can try the following methods.

Measure =
VAR _Cumulative1 = CALCULATE ( SUM ( 'Table'[Value] ),
        FILTER ( ALL ( 'Table' ),
            [# Month] <= SELECTEDVALUE ( 'Table'[# Month] )
                && [Service] = SELECTEDVALUE ( 'Table'[Service] ) ) )
VAR _Cumulative2 = CALCULATE ( SUM ( 'Table'[Value] ),
        FILTER ( ALL ( 'Table' ),
            [# Month] = SELECTEDVALUE ( 'Table'[# Month] )
                && [Service] <= SELECTEDVALUE ( 'Table'[Service] ) ) )
RETURN
    IF ( ISFILTERED ( 'Table'[Month] ), _Cumulative2, _Cumulative1 )

vzhangti_0-1676356288660.png

vzhangti_1-1676356319357.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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