Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

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 quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column.");
    VAR __LAST_DATE = LASTDATE('Dates'[Date].[Date])
    RETURN
        AVERAGEX(
            DATESBETWEEN(
                'Dates'[Date].[Date];
                DATEADD(__LAST_DATE; -30; DAY);
                __LAST_DATE
            );
            CALCULATE(AVERAGE('Dates'[Opened_cases_on_date]))
        )
)
 
To do this, I needed to accept Powerbi's date hierarchy. However, in my report I just want to show the date in 1 field (ex. Monday May 17 2019). When I go to my 'Values' pane, click on date and select 'Date' instead of 'Date Hierarchy', the date is shown in the correct way but the rolling average gives an error.
 
Is there a workaround?
1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

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.

image.png
Regards,
Mariusz

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

View solution in original post

1 REPLY 1
Mariusz
Community Champion
Community Champion

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.

image.png
Regards,
Mariusz

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

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors