Forum Discussion
12 Months rolling average
Hi , Anonymous
You need to add a dimension date table like this:
Date = ADDCOLUMNS( CALENDAR(FIRSTDATE('Table'[Date]) , LASTDATE('Table'[Date])) ,"Year_month", YEAR([Date])*100+ MONTH([Date]))
Then update the dax to this:
1212rollingaverage = var currdate = MAX('Date'[Date])
VAR last12months = EOMONTH(currdate, -12)+1
VAR last12monthyearmonth = YEAR(last12months)*100 + MONTH(last12months)
VAR curryearmonth = MAX('Date'[Year_month])
var t = SUMMARIZE(ALLSELECTED('Date'),'Case'[Year_month],"CaseId",[Countcaseid])
var t2 = FILTER(t,[Year_month] >= last12monthyearmonth && [Year_month] <= curryearmonth)
return
AVERAGEX(t2, [CaseId])
If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.(You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
I need to use casedatevalue as a slicer and when I select year for ex 2023. It should do the 12 month rolling average from the selected year i.e in this case 2023 and the current month. Example : If I select 2023 from slicer, it should do the rolling average from the current selected year taking into account the current date/month