Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Adding rolling average to a cumulative total

Hi,   I have a measure which calculates the cumulative total. Now I need to calculate the average of this cumulative total (from October 2017 until June 2021) and add it to the last calculated cumu...
  • v-deddai1-msft's avatar
    v-deddai1-msft
    5 years ago

    Hi Anonymous ,

     

    First, you should add an index column in your table, and then you can use the following calculated column:

    Cumulative Expenditure =
    VAR A =
        CALCULATE (
            SUM ( 'Table'[Expenditure] ),
            FILTER ( 'Table', 'Table'[Index] <= EARLIER ( 'Table'[Index] ) )
        )
    VAR B =
        'Table'[Index]
            - CALCULATE (
                MAX ( 'Table'[Index] ),
                FILTER ( 'Table', NOT ( ISBLANK ( 'Table'[Expenditure] ) ) )
            )
    RETURN
        IF (
            ISBLANK ( 'Table'[Expenditure] ),
            A
                + B * AVERAGE ( 'Table'[Expenditure] ),
            A
        )

    For more details, please refer to the pbix file.

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

    Best Regards,

    Dedmon Dai