Forum Discussion
sonshine14916
4 years agoRegular Visitor
Need help wit DAX Averagex(rolling average)
Hi, I am not able to achieve the intended result with AverageX DAX expression. Can you please help to understand what is wrong with my AverageX DAX expression. Background: I have simplified the pr...
- 4 years ago
Hi,
Please check the below picture and the attached pbix file.
I tried to create a sample pbix like below.
I hope the below can help to provide some ideas on how to apply it to your data model.
Value three months rolling avg: = VAR newtable = CALCULATETABLE ( ADDCOLUMNS ( SUMMARIZE ( Data, 'Calendar'[Month-Year] ), "@valuetotal", [Value total:] ), DATESINPERIOD ( 'Calendar'[Date], LASTDATE ( 'Calendar'[Date] ), -3, MONTH ) ) RETURN IF ( HASONEVALUE ( 'Calendar'[Month-Year] ), AVERAGEX ( newtable, [@valuetotal] ) )
Jihwan_Kim
Super User
4 years agoHi,
Please check the below picture and the attached pbix file.
I tried to create a sample pbix like below.
I hope the below can help to provide some ideas on how to apply it to your data model.
Value three months rolling avg: =
VAR newtable =
CALCULATETABLE (
ADDCOLUMNS (
SUMMARIZE ( Data, 'Calendar'[Month-Year] ),
"@valuetotal", [Value total:]
),
DATESINPERIOD ( 'Calendar'[Date], LASTDATE ( 'Calendar'[Date] ), -3, MONTH )
)
RETURN
IF (
HASONEVALUE ( 'Calendar'[Month-Year] ),
AVERAGEX ( newtable, [@valuetotal] )
)