cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jsflint
Frequent Visitor

Moving Average in Power Query M

How do you create a moving, or rolling, average in Power Query?  I already know how to do this in DAX, Excel, and Power BI, but I need to know how in Power Query.  Mainly because I need to use the resulting column in with other calculations.  

How could I do this on the example columns below?  I have a date column and random values in the second.  What would a 7 day moving average formula look like in Power Query M?

 

Thank you!

 

Date Value
1/1/2021 0.888073856
1/2/2021 0.087243733
1/3/2021 0.597531606
1/4/2021 0.25492501
1/5/2021 0.836644673
1/6/2021 0.253785258
1/7/2021 0.757333787
1/8/2021 0.958886707
1/9/2021 0.598108137
1/10/2021 0.180565909
1/11/2021 0.788755716
1/12/2021 0.888126908
1/13/2021 0.231740519
1/14/2021 0.107410191
1/15/2021 0.648458581
1/16/2021 0.582213204
1/17/2021 0.191300599
1/18/2021 0.864502562
1/19/2021 0.583108477

1 ACCEPTED SOLUTION

@jsflint 

This question was answered over here: 
https://community.powerbi.com/t5/Power-Query/Exponential-Moving-Average-in-Power-Query-M/m-p/1897358...


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Website   YouTube    LinkedIn   Join my Power BI User

View solution in original post

3 REPLIES 3
CNENFRNL
Super User III
Super User III

M is, no doubt, capable of processing data this way but is not inherently designated for such things.

Screenshot 2021-06-11 211303.png

jsflint
Frequent Visitor

Ok thanks.  Now a follow up question.  Is it possible to build an exponential moving average, of the same duration, off the simple moving average?

@jsflint 

This question was answered over here: 
https://community.powerbi.com/t5/Power-Query/Exponential-Moving-Average-in-Power-Query-M/m-p/1897358...


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Website   YouTube    LinkedIn   Join my Power BI User

View solution in original post

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Top Solution Authors
Top Kudoed Authors