Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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 Specialist
Solution Specialist

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.