Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Calculating Cumulative total of average using DAX expression

Hello there,    I am stuck with one scenario and having tough time figuring out the running total of averages using DAX expression, i would be glad if anyone could help me out on this,  below is t...
  • Anonymous's avatar
    Anonymous
    7 years ago

    Hi Anonymous,

     

    After play with your data, I create a measure to calculate cumulative average:

    Measure =
    VAR currYear =
        MAX ( OVC_data[OVC_YEAR] )
    RETURN
        SUMX (
            FILTER (
                SUMMARIZE (
                    ALLSELECTED ( OVC_data ),
                    [OVC_YEAR],
                    "Total Value", SUM ( OVC_data[OVC_Value] ),
                    "AVG Value", AVERAGE ( OVC_data[OVC_Value] )
                ),
                [OVC_YEAR] <= currYear
            ),
            [AVG Value]
        )
    

     

    Regards,

    Xiaoxin Sheng