Forum Discussion

siddhantk989's avatar
siddhantk989
Helper III
9 years ago
Solved

Not Getting proper result for 12M moving average

Hi All,      I have been working on 12month running average from long time and I am not able to figure out why I am getting some random values instead of getting my 12M rolling average.     I tri...
  • v-yulgu-msft's avatar
    v-yulgu-msft
    9 years ago

    Hi siddhantk989,

     

    In your scenario, you need to calculated the monthly total first. Please modify the measure [Rolling Average measure] as below:

    Monthly total =
    CALCULATE (
        SUM ( MasterData[Actual Sales] ),
        ALLEXCEPT (
            MasterData,
            MasterData[GL Date].[Year],
            MasterData[GL Date].[Month]
        )
    )
    
    Rolling Average measure =
    DIVIDE (
        CALCULATE (
            [Monthly total],
            FILTER (
                ALL ( MasterData ),
                MasterData[GL Date] > MAX ( MasterData[12 month ago] )
                    && MasterData[GL Date] <= MAX ( MasterData[GL Date] )
            )
        ),
        12
    )

     Regards,
    Yuliana Gu