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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Calculating an average across a data table and a calendar table

I'm having some issues putting this down in DAX formula, I have a table that has number of hours worked by people and I want to have a basic average formula of these hours across all the calendar table data I have, except for saturdays and sundays. The table looks something like this:

 

ID Day Hours

3331/02/20205
3331/02/20203

 

And then the result would be an average of these hours across all those days in the calendar table where there's respective data for (aside weekend). Can anyone help me out with a way to approach this?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I have managed to resolve this one at the end, I used this formula: 

 

var Employees = ADDCOLUMNS(Employees, "Daily Average Hours", CALCULATE(DIVIDE(SUM(Employees_Presence[Hours]), DISTINCTCOUNT(Employees_Presence[Date]))))
return

AVERAGEX(Employees, [Daily Average Hours])

 

Goes to create a table where every row has the average between the sum of the hours worked and the days they worked. Then, I take that table and recall the column I created above with AVERAGEX to obtain the average of the average hours for each.

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

I have managed to resolve this one at the end, I used this formula: 

 

var Employees = ADDCOLUMNS(Employees, "Daily Average Hours", CALCULATE(DIVIDE(SUM(Employees_Presence[Hours]), DISTINCTCOUNT(Employees_Presence[Date]))))
return

AVERAGEX(Employees, [Daily Average Hours])

 

Goes to create a table where every row has the average between the sum of the hours worked and the days they worked. Then, I take that table and recall the column I created above with AVERAGEX to obtain the average of the average hours for each.

amitchandak
Super User
Super User

@Anonymous , try a measure like 

 

calculate(average(Table[Hours]), filter(Table, weekday(Table[Date],2) <6 ) )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thank you, this seems to work fine. I think I just need to find a way to address employees who are not working there anymore, or the average will be brought down, but this is in another table. Maybe I can do a SELECT COLUMNS variable before and use that as a table

@Anonymous , depends on how data is stored. Refer current employee of this blog can help

https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

I have merged the column which tells me whether employees are dismissed or not. So right now it would look like the same as you mentioned but with that filter in addition. I can't make it however, because it says AVERAGEX can't work with Boolean types.

 

CALCULATE(AVERAGE(Employees, Employees[Dismissed] <> TRUE()), FILTER('Calendar', WEEKDAY('Calendar'[Date],2) <6))

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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