Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Rolling average on calculated table

Hi!   I have created a rolling average using 'quick measure'. Following dax is used: Opened_cases_on_date rolling average = IF(     ISFILTERED('Dates'[Date]);     ERROR("Time intelligence qui...
  • Mariusz's avatar
    7 years ago

    Hi Anonymous 

    Yes there is, please see the below

    Opened_cases_on_date rolling average =
    VAR __LAST_DATE = LASTDATE('Dates'[Date])
    RETURN
        AVERAGEX(
            DATESBETWEEN(
                'Dates'[Date];
                DATEADD(__LAST_DATE; -30; DAY);
                __LAST_DATE
            );
            CALCULATE(AVERAGE('Dates'[Opened_cases_on_date]))
        )

     

    You probobly want to mark your 'Dates' table as a 'date table' this will be requierd if you ever wont write any built in Time Inteligence  DAX Functions.


    Regards,
    Mariusz

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