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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
dtdat
New Member

How to calculate average of worktime from slicer date

Hi everyone.

My problem is the present working time of an employee in the company.
In the report, it has a date slicer, a count of working days, and the working hour of the employee in duration time.
Currently, I want to present average of working day and average working hour in duration time from date slicer.

My data below
Table 'working_time' has columns:
emloyee_id, workingdate, worktime_hrs (worktime hour in day), worktime_day (worktime day has default is 1)



Screenshot_161.png
Screenshot_162.png

Depend on table sum worktime group by employee, the sum worktime is the total value divided by 5 employees.
My expectation is the average of worktime_day should be (3+3+2+2+3) / 5 = 2.6 and the average of worktime_hrs should be (24+24+16+16+24) / 5 = 20.8.
But I don't know how to calculate this average value. 
I hope everyone will spare their precious time to help me solve this problem.
Thanks you so much!

1 ACCEPTED SOLUTION
Selva-Salimi
Solution Sage
Solution Sage

Hi @dtdat ,

 

you can write measures like,

workingtime_avg := var tbl1= summarize (working_table,employee_id, "working_time" ,sum(workingtime_hrs))

return sumx(tbl1,working_time)/distinctcount(employee_id)

and

workingday_avg := var tbl1= summarize (working_table,employee_id, "working_day" ,sum(workingtime_day))

return sumx(tbl1,working_day)/distinctcount(employee_id)

 

If this post helps, then I would appreciate a thumbs up  and mark it as the solution to help the other members find it more quickly. 

 

 

 

View solution in original post

2 REPLIES 2
dtdat
New Member

Hi @Selva-Salimi 

Wow, amazing!
I resolved this problem. You help me know more about DAX query processing techniques.
I appreciate your help.
Thank you very much!

Selva-Salimi
Solution Sage
Solution Sage

Hi @dtdat ,

 

you can write measures like,

workingtime_avg := var tbl1= summarize (working_table,employee_id, "working_time" ,sum(workingtime_hrs))

return sumx(tbl1,working_time)/distinctcount(employee_id)

and

workingday_avg := var tbl1= summarize (working_table,employee_id, "working_day" ,sum(workingtime_day))

return sumx(tbl1,working_day)/distinctcount(employee_id)

 

If this post helps, then I would appreciate a thumbs up  and mark it as the solution to help the other members find it more quickly. 

 

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.