cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mtrevisiol
Helper IV
Helper IV

How to duplicate rows based on two columns?

Hi everyone,

I've got a table that represents the hours of work of some employees.

It contains the name of the employee, the start date and time and the end date and time:

mtrevisiol_0-1643102263584.png

 

My intent is to duplicate each row to obtain a row containing the starting date and a row containing the ending date of each employee, something like this:

 

mtrevisiol_1-1643102351392.png

 

Because my intent is to create a relation between Table.DateStart and the Calendar Table. Do you know how can I do it, using Power Query? Thank you so much.

 

1 ACCEPTED SOLUTION

So before merging column create conditional column to check if DataStart <> DataEnd if true then merge : DataStart & "|" & DataEnd else null 

And now split this conditional column !

View solution in original post

4 REPLIES 4
freginier
Solution Supplier
Solution Supplier

In Power Query :

- Merge DataStart and DataEnd into one column with pipe ("|") delimiter for example

- Split this column on row (not column)

 

You should get what you want

 

@freginier thank you so much, it works!

mtrevisiol_0-1643103778460.png

But I have another problem: if I wanted to "split" only the rows where DataStart is different from DataEnd?

The ideal result would be this:

mtrevisiol_1-1643103848348.png

Thanks.

So before merging column create conditional column to check if DataStart <> DataEnd if true then merge : DataStart & "|" & DataEnd else null 

And now split this conditional column !

@freginier  thank you so much!

Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors