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
Bencreamer83
New Member

Rolling average by week number

Could someone help me with creating either a calculated column or measure to find a 4 week rolling average? I am using the week number and it seems as if the Dax calculations do not recognize the week number as an actual date. For example:
Week. Weekly avg: 4-week AVG:
21. 380
22. 420
23. 560
24. 310
25. 635
26. 570
1 ACCEPTED SOLUTION
Eric_Zhang
Employee
Employee

@Bencreamer83

 

One way to get the 4 weeks' rolling AVG. Sort by weekNo ascending and create an index column.

 

Capture.PNG

 

Then create a calculated column as

 

4 weeks' rolling avg = 
SUMX (
    FILTER (
        ALL ( Table4 ),
        Table4[Index] <= EARLIER ( Table4[Index] )
            && Table4[Index]
                > EARLIER ( Table4[Index] ) - 4
    ),
    Table4[sales]
)
    / COUNTX (
        FILTER (
            ALL ( Table4 ),
            Table4[Index] <= EARLIER ( Table4[Index] )
                && Table4[Index]
                    > EARLIER ( Table4[Index] ) - 4
        ),
        Table4[WeekNo]
    )

Capture.PNG

View solution in original post

2 REPLIES 2
Eric_Zhang
Employee
Employee

@Bencreamer83

 

One way to get the 4 weeks' rolling AVG. Sort by weekNo ascending and create an index column.

 

Capture.PNG

 

Then create a calculated column as

 

4 weeks' rolling avg = 
SUMX (
    FILTER (
        ALL ( Table4 ),
        Table4[Index] <= EARLIER ( Table4[Index] )
            && Table4[Index]
                > EARLIER ( Table4[Index] ) - 4
    ),
    Table4[sales]
)
    / COUNTX (
        FILTER (
            ALL ( Table4 ),
            Table4[Index] <= EARLIER ( Table4[Index] )
                && Table4[Index]
                    > EARLIER ( Table4[Index] ) - 4
        ),
        Table4[WeekNo]
    )

Capture.PNG

Thank you!

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.