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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Hwahab
Regular Visitor

calculating working hours per day for each employee

Hi , Need to calcuate working hours for each employee per day .

i done split the date time column to 2 columns ( date and Time )

 

The dataSet is look like the following

PowerBI.png

1 ACCEPTED SOLUTION
v-danhe-msft
Microsoft Employee
Microsoft Employee

Hi, based on my test , you can refer to below steps”

1.I have entered some sample data to test for your problem like the picture below.

1.PNG

2.Create a new measure to calculate your working hours.

Measure = var a=CALCULATE(MAX(Sheet1[Date Time]),FILTER(ALL(Sheet1),Sheet1[Action]="In"&&FORMAT(Sheet1[Date Time],"dd/mm/yyyy")=FORMAT(MAX(Sheet1[Date Time]),"dd/mm/yyyy")&&Sheet1[User ID]=MAX(Sheet1[User ID])))

          var b=CALCULATE(MAX(Sheet1[Date Time]),FILTER(ALL(Sheet1),Sheet1[Action]="Out"&&FORMAT(Sheet1[Date Time],"dd/mm/yyyy")=FORMAT(MAX(Sheet1[Date Time]),"dd/mm/yyyy")&&Sheet1[User ID]=MAX(Sheet1[User ID])))

          return DATEDIFF(a,b,MINUTE)/60

3.Create a Table visual and add the related fields and you can see the result.

2.PNG

You can also download the PBIX file to have a view.

https://www.dropbox.com/s/ehia0o2j5hnjp0s/calculating%20working%20hours%20per%20day%20for%20each%20e...

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-danhe-msft
Microsoft Employee
Microsoft Employee

Hi, based on my test , you can refer to below steps”

1.I have entered some sample data to test for your problem like the picture below.

1.PNG

2.Create a new measure to calculate your working hours.

Measure = var a=CALCULATE(MAX(Sheet1[Date Time]),FILTER(ALL(Sheet1),Sheet1[Action]="In"&&FORMAT(Sheet1[Date Time],"dd/mm/yyyy")=FORMAT(MAX(Sheet1[Date Time]),"dd/mm/yyyy")&&Sheet1[User ID]=MAX(Sheet1[User ID])))

          var b=CALCULATE(MAX(Sheet1[Date Time]),FILTER(ALL(Sheet1),Sheet1[Action]="Out"&&FORMAT(Sheet1[Date Time],"dd/mm/yyyy")=FORMAT(MAX(Sheet1[Date Time]),"dd/mm/yyyy")&&Sheet1[User ID]=MAX(Sheet1[User ID])))

          return DATEDIFF(a,b,MINUTE)/60

3.Create a Table visual and add the related fields and you can see the result.

2.PNG

You can also download the PBIX file to have a view.

https://www.dropbox.com/s/ehia0o2j5hnjp0s/calculating%20working%20hours%20per%20day%20for%20each%20e...

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Daniel , Thank you so much . i just found somthing related to logic and would like to share with you

as in this table the DAX cacluate working hours in negative (-) due to employees that work 12 hours direct ,

is there way to consdier this in the DAX ?

 

StatusUser IDNameClock TimeAtt. TypeType
New1Michael6/10/2018 21:31inPM
New1Michael6/11/2018 9:11outAM
New1Michael6/11/2018 21:24inPM

Thank you so much .

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors