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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

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
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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

Top Solution Authors