Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

MDXScript(Model) calculation Error

I am trying to create a simple moving average for my area chart and I keep getting the following error. "A column specified in the call to function 'datesbetween' is not of type date. this is not sup...
  • Anonymous's avatar
    Anonymous
    4 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 Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.