Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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
Solved! Go to Solution.
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.
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.
You can also download the PBIX file to have a view.
Regards,
Daniel He
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.
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.
You can also download the PBIX file to have a view.
Regards,
Daniel He
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 ?
| Status | User ID | Name | Clock Time | Att. Type | Type |
| New | 1 | Michael | 6/10/2018 21:31 | in | PM |
| New | 1 | Michael | 6/11/2018 9:11 | out | AM |
| New | 1 | Michael | 6/11/2018 21:24 | in | PM |
Thank you so much .
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!