Forum Discussion
Paulzz
9 years agoRegular Visitor
Cumulative sum pattern
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(Trans...
- 9 years ago
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.
Eric_Zhang
9 years agoMicrosoft Employee
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.
Paulzz
9 years agoRegular Visitor
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.