Centered Moving Average dax

Dear forum,
I have a good measure for moving average that works fine (pasted below) but I am stuck trying to iterate it to a centered moving average. For example, I would like to calculate the MA for previous 2 periods, current period, and next 2 periods to get a centered moving average but I’m stuck with not being clever enough to come up with the proper dax. Anyone have suggestions?

Moving Average Sales = 
IF( ISBLANK( [Sales] ),
    BLANK(),
AVERAGEX(
    DATESINPERIOD(
        Dates[Date],
        LASTDATE( Dates[Date] ),
        -3, MONTH ),
    [Sales] ) 
)

Thanks for your help!

Hi Brandon. I don’t have a dataset handy to verify, but perhaps you could use the pattern you already have and adjust the date period, e.g.,

Sales Centered 5M MA = 
// average from 2 months before to 2 months after
// adjust as desired to get the periods of interest
AVERAGEX(
		DATESINPERIOD( Dates[Date], 
            // start date is 2 months before current date
            DATEADD( LASTDATE( Dates[Date] ), -2, MONTH ), 
            // 4 month after start date
            4, MONTH ),
        [Total Sales] )

Does this look OK?

Thanks,
Greg

Hi @Brandon, we’ve noticed that no response has been received from you since the 13th of May. We just want to check if you still need further help with this post? In case there won’t be any activity on it in the next few days, we’ll be tagging this post as Solved. If you have a follow question or concern related to this topic, please remove the Solution tag first by clicking the three dots beside Reply and then untick the checkbox. Thanks!