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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
PaulDenne
Helper I
Helper I

17 week average

have got a date set of daily timesheets

have done a measure to summarise weekly hours

but can't get the average right to exclude zero weeks in the average 

even ones with all 17 weeks populated average doesn't seem quite right

 

Weekly Hours = CALCULATE(SUM('Detailed - Timesheet Report'[Regular Hours]), ALLEXCEPT('Detailed - Timesheet Report', 'Detailed - Timesheet Report'[Name], 'Date'[Current week], 'Date'[Year]) )
 
Rolling17CalendarWeekAvg =
VAR CurrentDate = MAX('Date'[Date])  // Use a date column from your Date table
VAR CurrentWeek = WEEKNUM(CurrentDate, 2)  // Get the current week number+VAR CurrentEmployee = SELECTEDVALUE('Detailed - Timesheet Report'[Name])
VAR CurrentEmployee = SELECTEDVALUE('Detailed - Timesheet Report'[Name])
VAR CurrentYear = YEAR(CurrentDate)  // Get the current year

RETURN
    CALCULATE(
        AVERAGEX(
            FILTER(
                ALL('Detailed - Timesheet Report'),
                'Detailed - Timesheet Report'[Year Week] >= (CurrentYear * 100 + CurrentWeek - 17) &&
                'Detailed - Timesheet Report'[Year Week] <= (CurrentYear * 100 + CurrentWeek) &&
                   'Detailed - Timesheet Report'[Name] = CurrentEmployee  // Ensure we filter for the current employee
            ),
            [Weekly Hours]
        ),
        ALLEXCEPT('Detailed - Timesheet Report', 'Detailed - Timesheet Report'[Name])
    )
 
PaulDenne_0-1730468175672.png

817 over 15 weeks shoudl be average 54 not average of 60 shown

1193.51 is close but shoudl be 70.2 not 69.9

 

have sample PBIX but couldn't se ehow to attach it 😞

1 ACCEPTED SOLUTION
adudani
Memorable Member
Memorable Member

hi @PaulDenne ,

 

Within the "Filter" in your measure, maybe add  " && CurrentWeek <> "Week 0" //whatever the week number not required is.

 

 

Also, an alternative method to calculate a dynamic moving average : How to Calculate Moving Averages in Power BI - The Ultimate Guide

 

P.S. you could upload a google/one drive link with the pbix file if this is not resolved.

 

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a Kudos 🙂
Kind Regards,
Avinash

View solution in original post

5 REPLIES 5
DataNinja777
Super User
Super User

Hi @PaulDenne ,

 

To address the discrepancy in your rolling 17-week average, you’ll want to ensure that weeks with zero hours are excluded from the calculation. This can be achieved by adding a filter to remove weeks with zero hours in your AVERAGEX function. Here’s an updated approach to your measure:

 

Rolling17CalendarWeekAvg =
VAR CurrentDate = MAX('Date'[Date])  // Use a date column from your Date table
VAR CurrentWeek = WEEKNUM(CurrentDate, 2)  // Get the current week number
VAR CurrentEmployee = SELECTEDVALUE('Detailed - Timesheet Report'[Name])
VAR CurrentYear = YEAR(CurrentDate)  // Get the current year

RETURN
    CALCULATE(
        AVERAGEX(
            FILTER(
                ALL('Detailed - Timesheet Report'),
                'Detailed - Timesheet Report'[Year Week] >= (CurrentYear * 100 + CurrentWeek - 17) &&
                'Detailed - Timesheet Report'[Year Week] <= (CurrentYear * 100 + CurrentWeek) &&
                'Detailed - Timesheet Report'[Name] = CurrentEmployee &&
                [Weekly Hours] > 0  // Exclude weeks with zero hours
            ),
            [Weekly Hours]
        ),
        ALLEXCEPT('Detailed - Timesheet Report', 'Detailed - Timesheet Report'[Name])
    )

Best regards,

hmm that didnt change the results so makes me wonder what period the avreage is looking at as know there was some zero weeks

PaulDenne
Helper I
Helper I
adudani
Memorable Member
Memorable Member

hi @PaulDenne ,

 

Within the "Filter" in your measure, maybe add  " && CurrentWeek <> "Week 0" //whatever the week number not required is.

 

 

Also, an alternative method to calculate a dynamic moving average : How to Calculate Moving Averages in Power BI - The Ultimate Guide

 

P.S. you could upload a google/one drive link with the pbix file if this is not resolved.

 

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a Kudos 🙂
Kind Regards,
Avinash

just watched video and got it to work using rolling average

 

many thanks

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors