Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by watching the DP-600 session on-demand now through April 28th.
Learn moreJoin the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now
I've attempted to follow the Ferrari / Russo DAX pattern for cumulative sum, where they suggest (based on their own sample data):
Cumulative Quantity = IF(MIN('Date'[Date]) <= CALCULATE(MAX(Transactions[Date]), ALL (Transactions)),
CALCULATE(SUM(Transactions[Quantity]), FILTER(ALL('Date'[Date]), 'Date'[Date] <= MAX('Date'[Date] ))))
The problem is that, when you use a slicer from the Date table (after joining it to Transactions) to filter a matrix visualisation down to 2013 only, the Cumulative Quantity measure is bringing through the SUM(Transactions[Quantity]) for all of the previous year and adding the 2012 amount to Jan 2013. This is shown in the two images below, showing before and after filtering. How can I change the above DAX so that Jan 2013 will show 3 for the Cumulative Quantity measure, rather than 5 (carrying on the 2012 total)? I need a way for the cumulative measure to effectively start from what is sliced, not the whole Date table. I've tried ALLSELECTED and other things -- I've got a feeling there's a second FILTER statement you could add to the second CALCULATE to do it, but I've had no luck so far.
Solved! Go to Solution.
ALLSELECTED shall work. Try
Cumulative Quantity =
IF (
MIN ( 'Date'[Date] )
<= CALCULATE ( MAX ( Transactions[Date] ), ALLSELECTED ( Transactions ) ),
CALCULATE (
SUM ( Transactions[Quantity] ),
FILTER ( ALLSELECTED ( 'Date' ), 'Date'[Date] <= MAX ( 'Date'[Date] ) )
)
)
Check a demo in the attached pbix.
ALLSELECTED shall work. Try
Cumulative Quantity =
IF (
MIN ( 'Date'[Date] )
<= CALCULATE ( MAX ( Transactions[Date] ), ALLSELECTED ( Transactions ) ),
CALCULATE (
SUM ( Transactions[Quantity] ),
FILTER ( ALLSELECTED ( 'Date' ), 'Date'[Date] <= MAX ( 'Date'[Date] ) )
)
)
Check a demo in the attached pbix.
Thanks for the quick response on that; my problem was omitting ALLSELECTED from the first part of the formula before the 2nd CALCULATE. Nice work.
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsCheck out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 43 | |
| 38 | |
| 35 | |
| 21 | |
| 15 |
| User | Count |
|---|---|
| 63 | |
| 58 | |
| 28 | |
| 27 | |
| 25 |