Forum Discussion
Calculate hours
- 3 years ago
Hi James_Galis1 again:)
If i understans you correctly after yoour response then something like that:
(I have done it in 3 steps to make it easier to follow , you can combine to 1)
1. Calculate for every employee first start time for each day :First_Start_time_Employee = CALCULATE(MIN('Table'[Start Time]), ALLEXCEPT('Table','Table'[Employee Name],'Table'[Visit Date]))2. Do the same with last end time:
Last_End Time_time_Employee = CALCULATE(MAX('Table'[End Time]), ALLEXCEPT('Table','Table'[Employee Name],'Table'[Visit Date]))3. Calculate difference between them in minuts and divide by 60 :Hours_Availble = DATEDIFF('Table'[First_Start_time_Employee],'Table'[Last_End Time_time_Employee],MINUTE)/60If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly
- 3 years ago
Hi James_Galis1
You can summarize your total worked hours with the following:Hours worked = CALCULATE(sumx('Table',DATEDIFF('Table'[Start Time],'Table'[End Time],MINUTE))/60, ALLEXCEPT('Table','Table'[Employee Name],'Table'[Visit Date]))and then calculate the delta:
Hours_Diff = [Hours_Availble]-[Hours worked]I updated a sample file with those new columns.
link is still Here
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly
Hi James_Galis1
My apologies, I didn't fully understand the calculation.
Are you interested in aggregation by day and employee?
- James_Galis13 years agoHelper II
Hi
Thank you for looking into this. I think the "hoursdiff" looks more like the " hours" column
I need to ensure the unworked hours for each date is captured accordinglyEg
Client 4 28/06/2023 Wednesday 9:30 10:00 Employee 1 0.5 5.5 Client 5 28/06/2023 Wednesday 10:00 11:00 Employee 1 1 5.5 Client 2 28/06/2023 Wednesday 11:00 12:00 Employee 1 1 5.5 Client 3 28/06/2023 Wednesday 14:00 15:00 Employee 1 1 5.5 The total hours worked =3.5
The available hours (9:30 - 15:00) = 5.5
The gap of 2 hours which is between client 2 and client 3 is what i need bring into calculation when considering the available hours column
Thanks
- Ritaf19833 years agoSuper User
Hi James_Galis1 again:)
If i understans you correctly after yoour response then something like that:
(I have done it in 3 steps to make it easier to follow , you can combine to 1)
1. Calculate for every employee first start time for each day :First_Start_time_Employee = CALCULATE(MIN('Table'[Start Time]), ALLEXCEPT('Table','Table'[Employee Name],'Table'[Visit Date]))2. Do the same with last end time:
Last_End Time_time_Employee = CALCULATE(MAX('Table'[End Time]), ALLEXCEPT('Table','Table'[Employee Name],'Table'[Visit Date]))3. Calculate difference between them in minuts and divide by 60 :Hours_Availble = DATEDIFF('Table'[First_Start_time_Employee],'Table'[Last_End Time_time_Employee],MINUTE)/60If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly
- James_Galis13 years agoHelper II
Thank You
This was what i was looking for