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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.