• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Overlapping times and calculating actual hours worked

excelmonk

New Member
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.

I would have multiple rows with different employees in my data. Is there an excel formula to create the column New Start Time. I'm open to use Power Query as well as I'm currently using that to consolidate data every day (or even DAX if that's easier)

Thanks for your help in advance!
 
Back
Top