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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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