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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

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

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
Top Kudoed Authors