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
Faz
New Member

Power Query Transpose/Unpivot Question

Hello,

 

I have multiple sources of data in the below format (PDF) where the data is below the header:

Faz_0-1682241301435.png

I am trying to make it so it combines all of the data sources and transforms them into the below format:

Faz_1-1682241435558.png

 

I have managed to do this with one data source through transposing, unpivoting columns and stacking columns etc. but when there are multiple data sources, the method that worked for one data source doesn't work for multiple due to it being in the wrong order when I do the final step of pivoting the column in an attempt to get the desired output I showed above.

 

Anyone got any advice?

 

2 REPLIES 2
Jakinta
Solution Sage
Solution Sage

As Imke replied you should better provide some samples of your pdf source files.

Meanwhile this might help.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WUtJRCkvMKU1VcEksSbUC8oAopCgxBUUgODUnR8G5tKgoNS+50kopVgesz1DfwlDfyMDIGKLIRN/IBIkbGuwCU4iCoGKOufmleSXFCgGJlYlJOakKSZVAZlFJpYIT1E6cChyhCpxKK7G4ycAAImtuDqHdnQLwOSMI4cmAovyU0uQSKM85Py8tsyhXIbgksaS0GGG+nhHUArfyFBSVqSlKsbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t, Column5 = _t, Column6 = _t]),
    List = List.Combine(Table.ToColumns(Source)),
    Headers = {"Value Date:","Trade Date:", "Sell Currency:", "Amounts Payable by Party B:", "Rate:", "Buy Currency:", "Amounts Payable by Party A:" },
    Indices = List.Transform (Headers, each List.PositionOf ( List, _)+1),
    Values = List.Transform (Indices, each List{_}),
    Promoted = Table.PromoteHeaders ( Table.FromRows({Headers,Values}) )
in
    Promoted
ImkeF
Community Champion
Community Champion

Hi @Faz ,
hard to tell without seeing what you actually did.
Can you share your M-code from the advanced editor please?

 

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

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.