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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Bilin_00
New Member

How to exclude future dates on rolling average dates

I am trying to exclude rolling average for the future days. Here is my formula, I tired all possible ways to exclude the future dates but nothing is working. Please give me some suggestions how to do this. I have attached screen clip of the table and my formula. Waiting for some suggestions and solution. Thank you!!

Rolling average.png

 In this priced column is count of each date from the orginal table. For instance, 12 on 24th April 2024 means 12 items has been priced.

 

Rolling Average 2 =
IF(
    ISFILTERED('Query2'[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('Query2'[Date].[Date])
    VAR __TODAY = TODAY()
    VAR __Calc =
        AVERAGEX(
            FILTER(
                DATESBETWEEN(
                    'Query2'[Date].[Date],
                    DATEADD(__LAST_DATE, -30, DAY),
                    DATEADD(__LAST_DATE, 0, DAY)
                ),
                'Query2'[Date].[Date] <= __TODAY
            ),
            CALCULATE(COUNTA('Query2'[Date]))
        )
    RETURN
        IF(MAX('Query2'[Date]) > __TODAY, BLANK(), __Calc)
5 REPLIES 5
lbendlin
Super User
Super User

Consider using WINDOW instead.

 

What is your expected result?

charts.png

I don't want rolling average line(black) after the red mark which is today date. I need last 30 days rolling average till today's date.

Rolling Average 2 =
IF(
    ISFILTERED('Query2'[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('Query2'[Date].[Date])
    VAR __TODAY = TODAY()
    VAR __Calc =
        AVERAGEX(
            FILTER(
                DATESBETWEEN(
                    'Query2'[Date].[Date],
                    DATEADD(__LAST_DATE, -30, DAY),
                    DATEADD(__LAST_DATE, 0, DAY)
                ),
                'Query2'[Date].[Date] <= __TODAY
            ),
            CALCULATE(COUNTA('Query2'[Date]))
        )
    RETURN
        IF(MAX('Query2'[Date]) > __LAST_DATE, BLANK(), __Calc)

It's displaying same output as before

lbendlin_0-1714049471907.png

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.