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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
mtrevisiol
Helper V
Helper V

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

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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