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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
maracles
Resolver II
Resolver II

Help needed with unpivot Power Query Transform

I've attached a screenshot which I think explains everything. I have a data table (green) which I need to transpose/unpivot using power query (Get & Transfrom) so that I get the table seen below (blue). I'm pretty sure I need to use unpivot but can't get it to work quite how I need it to. 

 

unpivot.png
Thanks. 

 

1 ACCEPTED SOLUTION
ImkeF
Community Champion
Community Champion

Check your column "OrderID"

Unpivot others

Split your column "Attribute" by space at the rightmost delimiter

Check column "Attribute.2"

Replace null by Amount

Pivot on this column

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

13 REPLIES 13
ImkeF
Community Champion
Community Champion

Check your column "OrderID"

Unpivot others

Split your column "Attribute" by space at the rightmost delimiter

Check column "Attribute.2"

Replace null by Amount

Pivot on this column

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

 

Thanks Imke for the response.

I've tried following the stps and have got as far as splitting the "Attribute" column which leaves me with the image below:

The rest of the steps don't seem to work though, I'm not sure how to replace 'Attribute 2' by Amount as there are no null values. 

Thanks. unpivot_solution_steps.png

ImkeF
Community Champion
Community Champion

Sorry, you need to split by length instead: 14

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Thanks, I've followed that step to get the below results but still cannot get the data in the format I need even after trying to do the pivot as suggested. Sorry, I feel really useless not being able to work this out (not used Pivot/Unpivot before)!

unpivot_attempt2.png

Anonymous
Not applicable

5) Pivot over the Attribute.3 column

 

pivotProblem (5).png

 

6) After that you can delete the unwanted columns and obtain your result.

 

pivotProblem (6).png

 

 

Let me know if it works.

 

#I'M Not An Expert#

@Anonymous

Thank you very much for the effort and useful diagrams. I ahve tried following those steps but when I pivot the Attribute 2 column in the way you describe I don't get the table that you show afterwards, instead I get this:

unpivot_attempt3.png

Any ideas?

Thanks. 

Thanks, I got it to work using your 'Split Columns' and using a value of 3 instead of 14, and then continuing from there. Much appreciated. 

ImkeF
Community Champion
Community Champion

Sorry, yes - the changed split-operation meant that a blank space has sneaked in. So the other solution would have been to Trim the Attribute.1-column before pivoting.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Anonymous
Not applicable

3) Select the Attribute column and split it by delimiter just like in the screenshot

pivotProblem (3).png

 

4) Replace the null values

 

pivotProblem (4).png

Anonymous
Not applicable

Hi @maracles,

 

  don't feel yourself useless! you just need to follow these easy steps :

 

 1) Get your table

 

pivotProblem (1).png

 

2) Select the OrderID column and Unpivot the other columns

 

 pivotProblem (2).png

 

ImkeF
Community Champion
Community Champion

You're nearly there 🙂

 

Now check the column "Attribute.2" and pivot on it.

Choose "Value" for the Value and no aggregates in the advanced options.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

@ImkeF Almost there! That gets me to this... how do I then merge the rows so that the 'Amount' and 'Date' for a particular Transaction are on the same row? 

I'll try and solve it myself but thought I'd get the answer now in case you're not around if I fail!

Thanks for the help, the Pivot/Unpivot feature looks like it could be very useful.  

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors