Forum Discussion

ElliotP's avatar
ElliotP
Post Prodigy
10 years ago
Solved

Moving Average

Hi,   I've just started using PowerBI and I'm a massive fan of the tool. I've been trying to calculate a simple moving average for Months vs Sessions.   I've tried quite a lot of things, googling...
  • v-sihou-msft's avatar
    v-sihou-msft
    10 years ago

    ElliotP

     

    Firstly you need a column of date with full date format. Then you can use calculated measure to get the expected result. Please refer to following steps.

     

    1. Create a calculated column for the date.
      FullDate =
      DATE ( 2016, 'Session'[Month of the Year], 1 )
      
    2. Create a measure for 3 months moving average. You can change the number of months if you want.
      Moving_Average_3_Months = 
      CALCULATE (
          AVERAGEX ( 'Session', 'Session'[Sessions] ),
          DATESINPERIOD (
              'Session'[FullDate],
              LASTDATE ( 'Session'[FullDate] ),
              -3,
              MONTH
          )
      )
      
    3. Drag the Line Chart into your canvas as below.