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
RD_PowerBI24
Helper I
Helper I

Previous Rolling Average from Rolling Average Quick Measure

Hi,

 

I've created a Rolling Average on sales using the quick measure feature on my date column.

I was given the pre-defined DAX code and I amended the intervals for DateAdd function so that it is dynamic and changes based on whether we look back 3, 6 or 12 months as an average using "Dynamic Rolling Average Value" as per below:

 

Rolling Average All_Sales =
IF(
    ISFILTERED('All_Sales'[All_Invoice_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 = ENDOFMONTH('All_Sales'[All_Invoice_Date].[Date])
    VAR __DATE_PERIOD =
        DATESBETWEEN(
            'All_Sales'[All_Invoice_Date].[Date],
            STARTOFMONTH(DATEADD(__LAST_DATE, 'Dynamic Rolling Average'[Dynamic Rolling Average Value], MONTH)),
            __LAST_DATE
        )
    RETURN
        AVERAGEX(
            CALCULATETABLE(
                SUMMARIZE(
                    VALUES('All_Sales'),
                    'All_Sales'[All_Invoice_Date].[Year],
                    'All_Sales'[All_Invoice_Date].[QuarterNo],
                    'All_Sales'[All_Invoice_Date].[Quarter],
                    'All_Sales'[All_Invoice_Date].[MonthNo],
                    'All_Sales'[All_Invoice_Date].[Month]
                ),
                __DATE_PERIOD
            ),
            CALCULATE([All_Sales], ALL('All_Sales'[All_Invoice_Date].[Day]))
        )
)

I am stuck on creating the previous rolling average which simply needs to be the same calculated rolling average but brought forward from previous months, depending on the dynamic selection of the time period. E.g. below is the output table I would desire ("Previous..." header columns is the measure to be created:

Can someone guide how to do to this, as I am stuck after various iterations to attempt to get this?
 
MonthR3MPrevious R3MR6M Previous R6M
Jan-23202470 202470 
Feb-23215690 215690 
Mar-23230155 230155 
Apr-23235618202470227331 
May-23249727215690236112 
Jun-23257043230155243599 
Jul-23269503235618252561202470
Aug-23260043249727254885215690
Sep-23244012257043250528230155
Oct-23235273269503252388227331
Nov-23235773260043247908236112
Dec-23239455244012241733243599
Jan-24234692235273234983252561
Feb-24236442235773236108254885
Mar-24235293239455237374250528
Apr-24248658234692241675252388
May-24237097236442236769247908
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @RD_PowerBI24 

Based on your description, you need to create a calendar table first.

Calendar = CALENDAR(DATE(2023,1,1),DATE(2024,5,1))

Then create a relationship between data table and calendar table.

vxinruzhumsft_0-1716951253275.png

 

Then create a measure

PreRM =
CALCULATE (
    [Rolling Average All_Sales],
    DATEADD (
        'Calendar'[Date],
        - MAX ( 'Dynamic Rolling Average'[Dynamic Rolling Average Value] ),
        MONTH
    )
)

Then put the date column of calendar table  and the measure to the visual.

vxinruzhumsft_3-1716951426670.png

 

Output

vxinruzhumsft_1-1716951356481.png

 

vxinruzhumsft_2-1716951365724.png

vxinruzhumsft_4-1716951446693.png

 

Best Regards!

Yolo Zhu

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

1 REPLY 1
Anonymous
Not applicable

Hi @RD_PowerBI24 

Based on your description, you need to create a calendar table first.

Calendar = CALENDAR(DATE(2023,1,1),DATE(2024,5,1))

Then create a relationship between data table and calendar table.

vxinruzhumsft_0-1716951253275.png

 

Then create a measure

PreRM =
CALCULATE (
    [Rolling Average All_Sales],
    DATEADD (
        'Calendar'[Date],
        - MAX ( 'Dynamic Rolling Average'[Dynamic Rolling Average Value] ),
        MONTH
    )
)

Then put the date column of calendar table  and the measure to the visual.

vxinruzhumsft_3-1716951426670.png

 

Output

vxinruzhumsft_1-1716951356481.png

 

vxinruzhumsft_2-1716951365724.png

vxinruzhumsft_4-1716951446693.png

 

Best Regards!

Yolo Zhu

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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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 Kudoed Authors