Overlapping times and calculating actual hours worked

excelmonk

New Member
Joined
Jul 7, 2012
Messages
3
Hi All,

Here is my scenario. I have a list of employees and the time ranges of when they have worked on different appointments. This data comes in every day and I would consolidate files for each day using power query. The sample data is as follows


EmployeeScheduled_StartScheduled_End
ABC4/14/2020 9:004/14/2020 16:00
DEF4/14/2020 9:004/14/2020 16:00
DEF4/14/2020 11:004/14/2020 14:00
ABC4/14/2020 15:004/14/2020 17:00
ABC4/14/2020 16:004/14/2020 18:30

I'm trying to calculate how many hours an employee worked on a particular days excluding the overlap times.

So for example employee ABC has three entries and all of them have some overlap. And same is the case with employee DEF. I'm trying to find a solution where I can define New Start Time where the new start time gets rid of the overlap problem.

For example


EmployeeScheduled_StartScheduled_EndNew Start TimeNew End TimeHours Worked
ABC4/14/2020 9:004/14/2020 16:004/14/2020 9:004/14/2020 16:007
DEF4/14/2020 9:004/14/2020 16:004/14/2020 9:004/14/2020 16:007
DEF4/14/2020 11:004/14/2020 14:004/14/2020 16:004/14/2020 14:000
ABC4/14/2020 15:004/14/2020 17:004/14/2020 16:004/14/2020 17:001
ABC4/14/2020 16:004/14/2020 18:304/14/2020 17:004/14/2020 18:301.5

For employee ABC for row 4 New start time is End time for ABC in row 1 and same way new start time in row 5 is same as end time in row 4. I follow the same logic for DEF.
To calculate working hours I simply check with if condition whether start time > End Time. And if start time is greater than end time I just make it 0. For example second row for DEF.

How can I implement this in Power BI by either creating a new column as in my example above or may be using a measure in DAX.

Thanks for your help in advance!

PS: I posted this in excel forum also as for now an excel solution is good enough but I want to implement this in Power BI in few months so it would be good to know how to do this in Power BI.
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,214,911
Messages
6,122,198
Members
449,072
Latest member
DW Draft

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top