Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hello
I am trying to calculate a rolling average. Its to calculate the yearly usage of a certain product over the last rolling 12 months and then from there I will calculate the daily average by working days (#260).
I was using this formula but it doesnt match the actual yearly usage based on historical data.
I have another formula but I also cant seem to get it 100% right across all products
Solved! Go to Solution.
Hi @AA622 ,
Please update the formula of your measure [UsageRolling6mo] as below and check if it works or not...
UsageRolling6mo =
VAR __MaxDate =
TODAY ()
VAR __EOM12 =
EOMONTH ( __MaxDate, -12 )
VAR __MinDate =
DATE ( YEAR ( __EOM12 ), MONTH ( __EOM12 ), DAY ( __MaxDate ) )
VAR __Table =
FILTER (
ALLSELECTED ( 'Calendar' ),
'Calendar'[Date] <= __MaxDate
&& 'Calendar'[Date] >= __MinDate
)
RETURN
AVERAGEX ( __Table, [Usage] )
In addition, you can refer the following links to get the rolling average values:
Rolling 12 Months Average in DAX
Best Regards
@AA622 Try:
Better RA =
VAR __MaxDate = TODAY()
VAR __EOM12 = EOMONTH(__MaxDate,-12)
VAR __MinDate = DATE(YEAR(__EOM12),MONTH(__EOM12),DAY(__MaxDate)
VAR __Table = FILTER(ALLSELECTED('Table'),[Date] <= __MaxDate && [Date] >= __MinDate)
RETURN
AVERAGEX(__Table,[Usage])
Both of the formulas you have currently are equally bad in my opinion because they do not account for leap years.
Better RA = VAR __MaxDate = TODAY() VAR __EOM12 = EOMONTH(__MaxDate,-12) VAR __MinDate = DATE(YEAR(__EOM12),MONTH(__EOM12),DAY(__MaxDate) VAR __Table = FILTER(ALLSELECTED('Table'),[Date] <= __MaxDate && [Date] >= __MinDate) RETURN AVERAGEX(__Table,[Usage])
HAving issues with the last VAR line. Line 5
Am I supposed to reference a table?
I tried referencing our Calendar Table. What would I put at the last line? I also seem to be having an issue with the mindate VAR in line 5
Hi @AA622 ,
Please update the formula of your measure [UsageRolling6mo] as below and check if it works or not...
UsageRolling6mo =
VAR __MaxDate =
TODAY ()
VAR __EOM12 =
EOMONTH ( __MaxDate, -12 )
VAR __MinDate =
DATE ( YEAR ( __EOM12 ), MONTH ( __EOM12 ), DAY ( __MaxDate ) )
VAR __Table =
FILTER (
ALLSELECTED ( 'Calendar' ),
'Calendar'[Date] <= __MaxDate
&& 'Calendar'[Date] >= __MinDate
)
RETURN
AVERAGEX ( __Table, [Usage] )
In addition, you can refer the following links to get the rolling average values:
Rolling 12 Months Average in DAX
Best Regards
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
89 | |
86 | |
82 | |
64 | |
49 |
User | Count |
---|---|
124 | |
110 | |
88 | |
68 | |
66 |