Forum Discussion

tstoski's avatar
tstoski
New Member
5 years ago

Add new rows based on time span condition

Hi everyone,

 

I am struggling to add new rows based on specific conditions using power query. Here is an example of what I want to do:

On my dataset I have a column for the start time and for the end time, which is related to machine working hours at work. We have 3 shifts during the day:

1st shift from 7am to 3pm

2nd shift from 3pm to 11pm 

3rd shift from 11pm to 7am

 

For example, if the start time is at 10 AM and the end time is at 4 PM, that means the machine was stopped during 6 hours, 5 hours in the first shift and 1 hour during the second shift, what I am trying to do is to split the rows in which one row has the start time at 10 AM and end time at 3 PM and create a second row where the start time is at 3 PM and end time at 4pm, keeping the same data on the other columns. Does anyone know how to solve this?

 

Thanks in advance.

1 Reply

  • v-easonf-msft's avatar
    v-easonf-msft
    Community Support

    Hi,  tstoski 

    You need to do column expansion in PQ . The question is beyond my capabilities.
    It is suggested to post your question to  Power Query forum as well,  where there are many proficient M query users.

     

    Best Regards,
    Community Support Team _ Eason