Forum Discussion

TimPowerBI's avatar
TimPowerBI
Frequent Visitor
6 years ago
Solved

Creating a cumulative cost over time based on slicer filter

Hi all,   I am trying to create a graph of cumulative cost over time based on what project is selected by the user on the dashboard.   Project Date Cost A 20/01/2020 10.00 B 20/01/2...
  • danextian's avatar
    6 years ago

    Hi TimPowerBI ,

     

    The solution will depend on how your data model is setup and can be achieved by using either a  column or a measure.
     Sol # 1: using a separate Date table.

    Cumulative Sum Measure =
    CALCULATE (
        SUM ( 'Fact'[Column] ),
        FILTER ( ALL ( 'Dates'[Date] ), 'Dates'[Date] <= MAX ( 'Dates'[Date] ) )
    )
    


    Sol # 2 :  no separate Dates table.

    Cumulative Sum Measure =
    CALCULATE (
        SUM ( 'Fact'[Column] ),
        FILTER ( ALL ( 'Fact'[Date] ), 'Fact'[Date] <= MAX ( 'Fact'[Date] ) )
    )
    


     Sol # 3: as a calculated column.

    Cumulative Sum Column = 
    CALCULATE (
        SUM ( 'Fact'[Column] ),
        FILTER (
            ALL ( 'Fact' ),
            'Fact'[Date] <= EARLIER ( 'Fact'[Date] )
                && 'Fact'[Category] = EARLIER ( 'Fact'[Category] )
        )
    )