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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
owdtelly88
Frequent Visitor

3 Week Rolling Average By Day of Week

Hi All,

 

I'm trying to create a rolling average based on total hours worked.

 

I need to group it by each day of the week, cost code and by worker.

 

My hours are in a table along with activity date, worker id and cost code. Each line is an entry against a cost code and a worker might have one line per day or several if they've been working on multiple cost codes. 

 

A worker won't necessarily work every day so some may be blank. 

 

Thanks in advance for any help. 

 

Chris 

 

 

1 ACCEPTED SOLUTION
v-xulin-mstf
Community Support
Community Support

Hi @owdtelly88,

 

Try measure as:

Measure = 
CALCULATE(
    AVERAGEX(FILTER(ALL('Table'),WEEKDAY('Table'[Date])=WEEKDAY(MAX('Table'[Date]))),'Table'[Value]),
    DATESINPERIOD('Table'[Date],MAX('Table'[Date]),21,DAY)
)

Here is the output:

vxulinmstf_0-1628067393500.png

 

The pbix is attached, please try it.

If you still have some question, please don't hesitate to let me known.‌‌

 

Best Regards,

Link

 

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution. Really appreciate!

View solution in original post

3 REPLIES 3
v-xulin-mstf
Community Support
Community Support

Hi @owdtelly88,

 

Try measure as:

Measure = 
CALCULATE(
    AVERAGEX(FILTER(ALL('Table'),WEEKDAY('Table'[Date])=WEEKDAY(MAX('Table'[Date]))),'Table'[Value]),
    DATESINPERIOD('Table'[Date],MAX('Table'[Date]),21,DAY)
)

Here is the output:

vxulinmstf_0-1628067393500.png

 

The pbix is attached, please try it.

If you still have some question, please don't hesitate to let me known.‌‌

 

Best Regards,

Link

 

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution. Really appreciate!

amitchandak
Super User
Super User

@owdtelly88 , Based on what I understand

averageX(summarize(Table, [activity date], [worker id] , [cost code] , "_1", [Measure]),[_1])

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks for your reponse. How would I incorporate the above into a three week rolling average please? Also, just to clarify, when you mention measure, you mean sum of hours?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors