Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
9 years ago
Solved

Rolling Average Help!

Hi everyone! I have been banging my head against the wall with this one for quite some time.  I have found some calculations in the forums that solve similar problems but I cannot for the life of ...
  • v-caliao-msft's avatar
    9 years ago

    Hi Anonymous,

     

    To achieve rolling average measure, you need to get the total value, and then use the total value divided by month number. Here is the sample DAX for you referebce.
    3 Month Moving Sum Units Sold] =
    CALCULATE([Units Sold],
              DATESINPERIOD(Calendar[Date],
                            LASTDATE(Calendar[Date]),-3, Month
                           )
             )


    [3 Month Moving Avg Corrected]=

    [3 Month Moving Sum Units Sold] /
    CALCULATE(DISTINCTCOUNT(Calendar[Year Month]),
              DATESINPERIOD(Calendar[Date],
                            LASTDATE(Calendar[Date]),-3,Month
                           )
             )

     

    Reference
    https://powerpivotpro.com/2013/07/moving-averages-sums-etc/
    http://www.sqlbi.com/articles/rolling-12-months-average-in-dax/

     

    Regards,

    Charlie Liao