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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Rolling average based on a specific date range

Hi there,

I would like to calculate my rolling average using a specific date range.  For example i have data from 2013 - 2019 but i want to calculate the rolling average only for 2017 - 2019. Here is where I am at thus far (tweaked the quick measure):

 

Sched Prin Sum rolling average =
IF(
    ISFILTERED('Starting and Closing Principal Balance Ex Orig Date'[CurrentDate]),
    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 = ENDOFMONTH('Starting and Closing Principal Balance Ex Orig Date'[CurrentDate].[Date])
    VAR __DATE_PERIOD =
        DATESBETWEEN(
            'Starting and Closing Principal Balance Ex Orig Date'[CurrentDate].[Date],
            STARTOFMONTH(DATEADD(__LAST_DATE, -([Moving Average Length Value]), MONTH)),
            __LAST_DATE
        )
    RETURN
        AVERAGEX(
            CALCULATETABLE(
                SUMMARIZE(
                    VALUES('Starting and Closing Principal Balance Ex Orig Date'),
                    'Starting and Closing Principal Balance Ex Orig Date'[CurrentDate].[Year],
                    'Starting and Closing Principal Balance Ex Orig Date'[CurrentDate].[QuarterNo],
                    'Starting and Closing Principal Balance Ex Orig Date'[CurrentDate].[Quarter],
                    'Starting and Closing Principal Balance Ex Orig Date'[CurrentDate].[MonthNo],
                    'Starting and Closing Principal Balance Ex Orig Date'[CurrentDate].[Month]
                ),
                __DATE_PERIOD
            ),
            CALCULATE(
                SUM('Starting and Closing Principal Balance Ex Orig Date'[Scheduled Principal Payment]),
                ALL('Starting and Closing Principal Balance Ex Orig Date'[CurrentDate].[Day])
            )
        )
)
 
The field named Moving Average Length Value is actually a parameter that lets me define the number of months I would like to use as part of the moving average, i want to actually use a parameter to define my starting and ending dates.  Any suggestions?
1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Please refer to this blog

Moving Averages Controlled by Slicer

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
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

2 REPLIES 2
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Is this problem sloved? 

If it is sloved, could you kindly accept it as a solution to close this case?

If not, please let me know.

 

Best Regards

Maggie

v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Please refer to this blog

Moving Averages Controlled by Slicer

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Top Solution Authors