Forum Discussion

Paulzz's avatar
Paulzz
Regular Visitor
9 years ago
Solved

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...
  • Eric_Zhang's avatar
    9 years ago

    MFelix

    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.