Forum Discussion

rogerdea's avatar
rogerdea
Icon for Helper IV rankHelper IV
6 years ago
Solved

Rolling 3 Year Average

Hello   I am trying to figure out how to calculate this from my data and struggling with this.  I need the rolling 3 year average of the sum of units, taking into account that for the first year th...
  • v-xuding-msft's avatar
    6 years ago

    Hi rogerdea ,

    Please try like this:

    • Create a calendar table.

     

    Date =
    VAR _calendar =
        CALENDAR ( MIN ( 'Table'[Date] ), MAX ( 'Table'[Date] ) )
    RETURN
        ADDCOLUMNS ( _calendar, "Year", YEAR ( [Date] ) )
    

     

    • Create a measure.

     

    Measure =
    DIVIDE (
        CALCULATE (
            SUM ( 'Table'[Unit] ),
            DATESINPERIOD ( 'Date'[Date], MAX ( 'Date'[Date] ), -3, YEAR )
        ),
        CALCULATE (
            DISTINCTCOUNT ( 'Date'[Year] ),
            DATESINPERIOD ( 'Date'[Date], MAX ( 'Date'[Date] ), -3, YEAR )
        )
    )
    

     

    For more details, please see the attachment.

     

    Best Regards,

    Xue Ding

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