Forum Discussion

AA622's avatar
AA622
Helper II
3 years ago
Solved

Rolling yearly Average

Hello   I am trying to calculate a rolling average. Its to calculate the yearly usage of a certain product over the last rolling 12 months and then from there I will calculate the daily average by ...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi AA622 ,

    Please update the formula of your measure [UsageRolling6mo] as below and check if it works or not...

    UsageRolling6mo =
    VAR __MaxDate =
        TODAY ()
    VAR __EOM12 =
        EOMONTH ( __MaxDate, -12 )
    VAR __MinDate =
        DATE ( YEAR ( __EOM12 ), MONTH ( __EOM12 ), DAY ( __MaxDate ) )
    VAR __Table =
        FILTER (
            ALLSELECTED ( 'Calendar' ),
            'Calendar'[Date] <= __MaxDate
                && 'Calendar'[Date] >= __MinDate
        )
    RETURN
        AVERAGEX ( __Table, [Usage] )

    In addition, you can refer the following links to get the rolling average values:

    Rolling Averages In Power BI

    Rolling 12 Months Average in DAX

    Best Regards