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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Quest77
New Member

4 / 13/ 52 Week Rolling Averages

Hi I am trying to create a number of cards that contain the following rolling averages. 4 week, 13 week and 52 week. I don't know what measure to create in order to achieve these reults. I can try and send the sample file but not sure best way to attach it. 

Link to sample file attached

 

https://1drv.ms/u/s!AiZ1-kl9lagZgt4olcKdIRRuzIxiEg?e=bbrnvL

 

 

Data Table

Quest77_3-1671903114098.png

Calendar Table

Quest77_2-1671903091983.png

Visual I am trying to achieve for weekly averages

Quest77_1-1671903061375.png

Weekly Sum Matrix already built

Quest77_0-1671903022666.png

 

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

@Quest77 

See it all at work in the attached file (Overview page)

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

View solution in original post

7 REPLIES 7
AlB
Community Champion
Community Champion

@Quest77 

See it all at work in the attached file (Overview page)

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

When i used the same function to create measure current week offset, it got failed due to an error that a single value cannot be determined. Anyway i can connect with you about this problem? Thank you very much.

AlB
Community Champion
Community Champion

@Quest77 

Exactly same pattern for the 13 and 52 week. Only the variable at the top changes 

13 Week Rolling Average = 
VAR numWeeks_ = 13
VAR weeksT_ =
    CALCULATETABLE (
        DISTINCT ( 'Calendar'[CurrentWeekOffset] ),
        'Calendar'[CurrentWeekOffset] >= - numWeeks_,
        'Calendar'[CurrentWeekOffset] <= 0,
        ALL ( 'Calendar' )
    )
RETURN
    CALCULATE (
        AVERAGEX ( weeksT_, CALCULATE ( SUM ( SETTLEMENT_STATEMENTS[Sales] ) ) ),
        ALL ( 'Calendar' )
    )

 

52 Week Rolling Average = 
VAR numWeeks_ = 52
VAR weeksT_ =
    CALCULATETABLE (
        DISTINCT ( 'Calendar'[CurrentWeekOffset] ),
        'Calendar'[CurrentWeekOffset] >= - numWeeks_,
        'Calendar'[CurrentWeekOffset] <= 0,
        ALL ( 'Calendar' )
    )
RETURN
    CALCULATE (
        AVERAGEX ( weeksT_, CALCULATE ( SUM ( SETTLEMENT_STATEMENTS[Sales] ) ) ),
        ALL ( 'Calendar' )
    )

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

AlB
Community Champion
Community Champion

@Quest77 

First create a calculated column with the number of weeks offset from the current week for each date in the Calendar table. This will simplify the measures:

CurrentWeekOffset = 
VAR currentWeekStart_ =
    DATEVALUE (
        LOOKUPVALUE ( 'Calendar'[Week Start Date], 'Calendar'[Date], TODAY () )
    )
VAR currentRowWeekStart_ = 'Calendar'[Week Start Date]
RETURN
    DATEDIFF ( currentWeekStart_, currentRowWeekStart_, WEEK )

 

Then build the measure for the 4 week rolling average. Note it is going back from the current date

4 Week Rolling Average V2 = 
VAR numWeeks_ = 4
VAR weeksT_ =
    CALCULATETABLE (
        DISTINCT ( 'Calendar'[CurrentWeekOffset] ),
        'Calendar'[CurrentWeekOffset] >= - numWeeks_,
        'Calendar'[CurrentWeekOffset] <= 0,
        ALL ( 'Calendar' )
    )
RETURN
    CALCULATE (
        AVERAGEX ( weeksT_, CALCULATE ( SUM ( SETTLEMENT_STATEMENTS[Sales] ) ) ),
        ALL ( 'Calendar' )
    )

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

If my date table already has week start date, do we still need calendarweekoffset? When i tried to create the first measure, it didn't work.

AlB
Community Champion
Community Champion

Hi @Quest77 

You have to share the URL to the file hosted elsewhere: Dropbox, Onedrive... or just upload the file to a site like tinyupload.com (no sign-up required).


SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

I attached the sample file via link in my original post

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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