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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
shubhamc_002
Helper I
Helper I

Cumulative Sum based on multiple filter context

Hi Team , 

 

Need one help on one scenario in DAX. 
I want to create a measure for cumulative sum which can Dynamically accept the external filter context without hardcoding in measure. Below measure is perfectly working fine but this solution is like hardcoding field names(  'Table 2'[Column1], 'Table 2'[Column2], 'Table 2'[Column3]) in allexcept is not appropriate solution.
 Our requirement is to generate cumulative sum of total sales based on multiple filter context dynamically instead of hardcoding field names in all except.

measure = 
Calculate(
      [Total Sales], 
       filter(
          Allexcept('Table 1',
                           'Table 2'[Column1],
                             'Table 2'[Column2], 
                               'Table 2'[Column3]), 
                                 'Table 1'[order Date]<=MAX('Table 1'[order Date])
                           )
                      )
Please let us know if this can be done by any other approach. 


Thanks

1 REPLY 1
amitchandak
Super User
Super User

@shubhamc_002 , You should use a separate date table and try

 

Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(all('Date'),'Date'[date] <=max('Date'[date])))

 

or

Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(allselected(date),date[date] <=max(date[Date])))

 

Running Total/ Cumulative: https://www.youtube.com/watch?v=h2wsO332LUo&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=41

 

 

You can consider Window function

Power BI Window function Rolling, Cumulative/Running Total, WTD, MTD, QTD, YTD, FYTD: https://youtu.be/nxc_IWl-tTc

 

Power BI Webinar- How to take advantage of New Power Bi Functions Offset,Window, Index:
https://youtube.com/live/exk8F5ka1Nw

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.