Forum Discussion
MDXScript(Model) calculation Error
- Anonymous4 years ago
Hi Anonymous ,
I suggest you to create a DimDate table with continuous date if you want to use DATESBETWEEN() which is a time intelligence function.
Try CALENDAR() or CALENDARAUTO().
DimDate = ADDCOLUMNS( CALENDARAUTO(),"Year",YEAR([Date]),"Month",MONTH([Date]))My Sample:
Measure:
Measure = AVERAGEX( DATESBETWEEN(DimDate[Date],MIN(DimDate[Date]),MAX(DimDate[Date])), CALCULATE(sum('Data (10)'[Count])) )Then add Year/Month columns into Axis. Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello, that still didn't work. I did not get an error in DAX but when I input the measure in my chart it did not add a simple moving average (SMA).
Hi Anonymous ,
I suggest you to create a DimDate table with continuous date if you want to use DATESBETWEEN() which is a time intelligence function.
Try CALENDAR() or CALENDARAUTO().
DimDate = ADDCOLUMNS( CALENDARAUTO(),"Year",YEAR([Date]),"Month",MONTH([Date]))
My Sample:
Measure:
Measure =
AVERAGEX(
DATESBETWEEN(DimDate[Date],MIN(DimDate[Date]),MAX(DimDate[Date])),
CALCULATE(sum('Data (10)'[Count]))
)
Then add Year/Month columns into Axis. Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.