Split time if timespans overlaps

If a employee starts working on 2 workorders i would like to split his workhours so the sum is equal to his total hours at work.

For the example in the picture. Two jobs are started and the total hours (UnitTime) are 4,4+8,2 but the employee wasnt at work for 4,4+8,2 hours. How can I split the UnitTime based on the clock stamps in “StartTidtagarur” and “Reported when”?

image

It's not clear what the result should look like. Can you provide an example of such a split?

I want to split time put on parallel workorder. The solution i went with was to create a time axis on minute level. Then check for active orders per minute and employee and divided that minute by the number of active order. It gets the job done but creates alot of rows before aggregating it at the end.

I'm not sure I understand it. Can you provide an example with exact numbers - data before, and data after the necessary calculation?

In the picture in my first post we can see that we get the hours from both orders as a sum. If I translate to this picture, i get the sum of all the hours in the blue bars: 9 + 7 +3 = 19 but i want the result to represent person1:s presence hours which is 9 hours. Therefore the hours needs to be split according to this picture.

Here is an approach and some test data.

Hope it helps. Had more fun with that than solving a sudoku. :smiley:

Split time if timespans overlaps - test data.dset (1.3 KB)

Split time if timespans overlaps.morph (15.3 KB)