Forum Discussion
17 week average
- 1 year ago
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.
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,
- PaulDenne1 year agoHelper I
hmm that didnt change the results so makes me wonder what period the avreage is looking at as know there was some zero weeks