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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
RapidRestore
New Member

Help with transposing rows if column is the same.

I would like to use Power Query to transform the table below (Before) to the (After).

The idea would be to transpose rows (Sub Invoice#, Task Descriton, Price) to additional columns if the (InvoiceNumber) column matches.

 

Before

BeforeBefore

After

image.png

 

Thank you!

1 ACCEPTED SOLUTION
wdx223_Daniel
Community Champion
Community Champion

=let col=Table.ColumnNames(Before) in Table.Combine(Table.Group(Before,"InvoiceNumber",{"n",each Table.FromRows({{[InvoiceNumber]{0}}&List.Combine(Table.ToRows(Table.SelectColumns(_,List.Skip(col))))},List.TransformMany({0..Table.RowCount(_)-1},each if _=0 then col else List.Skip(col),(x,y)=>if x=0 then y else y&" - "& Text.From(x+1)))})[n])

View solution in original post

1 REPLY 1
wdx223_Daniel
Community Champion
Community Champion

=let col=Table.ColumnNames(Before) in Table.Combine(Table.Group(Before,"InvoiceNumber",{"n",each Table.FromRows({{[InvoiceNumber]{0}}&List.Combine(Table.ToRows(Table.SelectColumns(_,List.Skip(col))))},List.TransformMany({0..Table.RowCount(_)-1},each if _=0 then col else List.Skip(col),(x,y)=>if x=0 then y else y&" - "& Text.From(x+1)))})[n])

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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