Forum Discussion
Syndicate_Admin
3 years agoAdministrator
QUERY - DAX code for Exponential Moving Average calculation - EMA
Hello PBI community.
Any experts to guide me on how to break down the DAX code to calculate the Exponential Moving Average for 30 days?
Thanks a lot
RJRO
- Anonymous3 years ago
HI RAFAJRO,
You can create a variable to store the current axis date and use it as conditions to filter on your fact table records and get rolling average based on specific date ranges.
formula = VAR currdate = MAX ( Calendar[Date] ) RETURN CALCULATE ( AVERAGE ( Table[Amount] ), FILTER ( ALLSELECTED ( Table ), [Date] >= currdate - 30 && [Date] <= currDate ) )Regards,
Xiaoxin Sheng
1 Reply
- AnonymousNot applicable
HI RAFAJRO,
You can create a variable to store the current axis date and use it as conditions to filter on your fact table records and get rolling average based on specific date ranges.
formula = VAR currdate = MAX ( Calendar[Date] ) RETURN CALCULATE ( AVERAGE ( Table[Amount] ), FILTER ( ALLSELECTED ( Table ), [Date] >= currdate - 30 && [Date] <= currDate ) )Regards,
Xiaoxin Sheng