cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gany
New Member

3 month rolling average in POWERQUERY as Custom Column

Hi guys

 

I have this table created by transformation->grouping + merging fields from other table 

 

I need to create aditional column with rolling 3 month calculation in POWER QUERY by adding Custom Column

example : For Jan 2022 (Jan 22+Dec21+Nov21)/3 =(6.44+9.18+6.45)/3=7.36 

                 For Dec 2021 (Dec21+Nov21+Oct21)/3 =(9.18+6.45+2.07)/3=5.9

 

This table name : PREMIUM WORKFLOW( 1)  TableTable

Can anyone pls help ?

1 ACCEPTED SOLUTION
v-polly-msft
Community Support
Community Support

Hi @gany ,

Please have a try.

 

(x)=>
List.Average(Table.SelectRows(#"Renamed Columns", (row)=>List.Contains(List.MaxN(List.Select(#"Renamed Columns"[Period], (y)=>y<=x[Period]),3), row[Period]))[Value])

 

vpollymsft_0-1643351817589.png

Best Regards

Community Support Team _ Polly

 

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

 

 

View solution in original post

8 REPLIES 8
v-polly-msft
Community Support
Community Support

Hi @gany ,

Please have a try.

 

(x)=>
List.Average(Table.SelectRows(#"Renamed Columns", (row)=>List.Contains(List.MaxN(List.Select(#"Renamed Columns"[Period], (y)=>y<=x[Period]),3), row[Period]))[Value])

 

vpollymsft_0-1643351817589.png

Best Regards

Community Support Team _ Polly

 

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

 

 

Amazing, thanks a lot

parry2k
Super User
Super User

@gany I see, I don't have a handy solution for that and I'm not sure if I'm going to spend time to make it happen. I hope someone else can help. Good luck!






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

Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.





Ok, thanks anyway

parry2k
Super User
Super User

@gany not sure what to say. What have you tried? Are you getting errors or wrong results? Can you share more details?






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

Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.





I'm trying to add this as a custom column withing power query .

 

I got it working as a measure but that is not what i need, i need to expand table by aditional column (in power query)

parry2k
Super User
Super User

@gany there are so many articles on it, here is link to one Rolling 12 Months Average in DAX - SQLBI

 

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.






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

Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.





Thanks for the reply...i saw that one ...still dont understand the logic and was not able to use it.

Helpful resources

Announcements
May 23 2022 epsiode 5 without aka link.jpg

The Power BI Community Show

Welcome to the Power BI Community Show! Jeroen ter Heerdt talks about the importance of Data Modeling.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through June10th!

Power BI Dev Camp Session 22 without aka link and time 768x460.jpg

Check it Out!

Watch Session 22 Ted's Dev Camp along with past sessions!

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!

Top Kudoed Authors