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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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