Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi Everyone,
Could anyone please help me with Dax for the last 6 months rolling average and it has to be dynamic as selection with months.
Early responses are highly appreciated.
Thanks & Regards
Manoj
Solved! Go to Solution.
Hi @manojbariki1987 ,
Using Calculation Groups:
Calculation groups allow you to dynamically switch measures based on slicer selections. In your case, we’ll create a calculation group to handle the rolling average.
Here are the steps:
Create a New Table:
Previous Date = 'Date' Copy
Link the Tables:
Write a DAX Measure:
Rolling Average =
VAR SelectedDate = MAX('Date'[Date])
VAR RollingMonths = DATESINPERIOD('Previous Date'[Date], LASTDATE('Date'[Date]), -6, MONTH)
VAR AvgSales = AVERAGEX(RollingMonths, [Sales Amount])
RETURN IF(HASONEVALUE('Date'[Month]), AvgSales, BLANK())
Best Regards,
Xianda Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @manojbariki1987 ,
Using Calculation Groups:
Calculation groups allow you to dynamically switch measures based on slicer selections. In your case, we’ll create a calculation group to handle the rolling average.
Here are the steps:
Create a New Table:
Previous Date = 'Date' Copy
Link the Tables:
Write a DAX Measure:
Rolling Average =
VAR SelectedDate = MAX('Date'[Date])
VAR RollingMonths = DATESINPERIOD('Previous Date'[Date], LASTDATE('Date'[Date]), -6, MONTH)
VAR AvgSales = AVERAGEX(RollingMonths, [Sales Amount])
RETURN IF(HASONEVALUE('Date'[Month]), AvgSales, BLANK())
Best Regards,
Xianda Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
create w dimdate table .
link it to your fact.
check this article. would help you .
https://www.sqlbi.com/articles/rolling-12-months-average-in-dax/
let me know this works for you.
If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution ✅
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
97 | |
96 | |
81 | |
74 | |
66 |
User | Count |
---|---|
126 | |
106 | |
105 | |
86 | |
72 |