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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
HFG
New Member

Pivoting multiple columns side by side

Hi all, 

 

I'm very new to Power Query and don't know much about M so I'm turning to you for help. I have a table of repair tickets with a line per ticket  and multiple "Reason" columns and the same number of "Photo" columns. I am trying to transfer this data to a new normalised database where I have a ticket column, a reason column and a photo column. I am attempting to transform the data in Power Query. In the attached image, A is what I have, B is what I would like and C is where I have ended up by unpivoting the table. Could you help me achieve what I need please ? 

HFG_0-1684338318169.png


Thanks

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @HFG ,

 

Here's my solution.

Sample data:

vstephenmsft_0-1684727457157.png

 

1.Duplicate it.

vstephenmsft_1-1684727472991.png

2.In Table, select only reason columns and unpivot them, remove all photo columns.

vstephenmsft_4-1684727568128.png

3.Split Attribute column.

vstephenmsft_5-1684727594647.png

vstephenmsft_6-1684727603936.png

4.Remove Attribute.1 column.

vstephenmsft_7-1684727621443.png

5.In the duplicated table, follow the same steps as before, but keep the Photo columns and remove the Reason columns.

vstephenmsft_8-1684727690619.png

 

6.Merge them. You need to notice that there are two matching columns.

vstephenmsft_9-1684727704677.png

vstephenmsft_10-1684727741326.png

vstephenmsft_12-1684727787213.png

 

7.Expand them and remove unneeded columns, rename them.

vstephenmsft_11-1684727777342.png

 

You can download my attachment for more details.

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.           

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @HFG ,

 

Here's my solution.

Sample data:

vstephenmsft_0-1684727457157.png

 

1.Duplicate it.

vstephenmsft_1-1684727472991.png

2.In Table, select only reason columns and unpivot them, remove all photo columns.

vstephenmsft_4-1684727568128.png

3.Split Attribute column.

vstephenmsft_5-1684727594647.png

vstephenmsft_6-1684727603936.png

4.Remove Attribute.1 column.

vstephenmsft_7-1684727621443.png

5.In the duplicated table, follow the same steps as before, but keep the Photo columns and remove the Reason columns.

vstephenmsft_8-1684727690619.png

 

6.Merge them. You need to notice that there are two matching columns.

vstephenmsft_9-1684727704677.png

vstephenmsft_10-1684727741326.png

vstephenmsft_12-1684727787213.png

 

7.Expand them and remove unneeded columns, rename them.

vstephenmsft_11-1684727777342.png

 

You can download my attachment for more details.

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.           

 

Thank you, that worked well.

AjithPrasath
Resolver II
Resolver II

Hi,
to get the desired result , please follow the steps below in power query editor:
1. Select only reason columns and unpivot them
2. Remove the attribute column from the table
3. Select photos column and unpivot them
4. Remove the attribute column from the table
5. Select the two value columns and remove the duplicates by right click
6. Change the column names to reason and photos

 

AjithPrasath_0-1684340190892.png

Output:

AjithPrasath_1-1684340223505.png

If your solution is met please mark this as solution.

Thanks,

AJ

Hi @AjithPrasath , 

 

Thanks for much that worked really well. The only thing that doesn't seem to have worked is the deleting duplicates. I had 18K lines when I unpivoted just the reasons and now I have 20K and I can see duplicate lines. Do you know any reason why it might not have deleted all the duplicates ?

Helpful resources

Announcements
Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.