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

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

Reply
Baubek777
New Member

Advanced data transformation in Power Query

Hi,

 

I have an issue with transforming the data loaded from a pdf file to Power BI.

The raw data looks like this: 

 

New-York
Metallurgy
Client-10, CNY rate 2.90%, USD rate 2.70%, EUR rate 1.90%
Client-8, CNY rate 3.40%, USD rate 2.50%, EUR rate 1.30%
Client-9, CNY rate 2.80%, USD rate 2.70%, EUR rate 0.70%
Oil and gas
Client-11, CNY rate 5.60%, USD rate 1.10%, EUR rate 1.90%
Chemical engineering
Client-12, CNY rate 0.50%, USD rate 2.30%, EUR rate 0.30%
Client-13, CNY rate 3.50%, USD rate 0.40%, EUR rate 0.50%
Los-Angeles
Metallurgy
Client-17, CNY rate 1.30%, USD rate 1.70%, EUR rate 1.40%
Oil and gas
Client-14, CNY rate 3.10%, USD rate 2.50%, EUR rate 0.50%
Client-15, CNY rate 5.20%, USD rate 1.70%, EUR rate 1.10%
Chemical engineering
Client-16, CNY rate 3.90%, USD rate 2.90%, EUR rate 1.80%
State bodies, authorities
Client-18, CNY rate 4.20%, USD rate 0.00%, EUR rate 0.20%
Client-19, CNY rate 5.60%, USD rate 2.70%, EUR rate 1.10%

 

I want it to get transformed into this format:

 

New-YorkMetallurgyClient-10CNY rate 2.90%
New-YorkMetallurgyClient-10USD rate 2.70%
New-YorkMetallurgyClient-10EUR rate 1.90%
New-YorkMetallurgyClient-8CNY rate 3.40% 
New-YorkMetallurgyClient-8USD rate 2.50%,
New-YorkMetallurgyClient-8EUR rate 1.30%
New-YorkMetallurgyClient-9CNY rate 2.80%
New-YorkMetallurgyClient-9USD rate 2.70%
New-YorkMetallurgyClient-9EUR rate 0.70%
And so on   

 

Please, note:

1. There can be any number of industries in each city

2. There can be any number of clients in each industry

3. Client names in the source file can be the same, but those clients can be different, because they may belong to different industries in different cities. 

 

Would you please describe step-by-step how to transform the data into desired format? Thank you in advance!

1 REPLY 1
wdx223_Daniel
Super User
Super User

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jZPNasMwEIRfRRh6s4Xkn8Q+lrS3NoWGHILJQWkWRVSVQVYofftiO6HaLXV6HMw3mtldt22yhs9s1/n3ZJ+2yTMEZe3Z669RrqwBFzIpUrZa75hXAVjOG3GXsu3m4aqXg37cvk5aDt9juo7ggpcErghcYLhBL9ezL4tBj/CLsUy5I9OqRz1k5FbxBXKTXP7V4wQf5k1ZBk4bB+CN08g2j2zF1CgKWZCQpKEs0HwwLaZ5RXR1oZ+6Prt3Giz0c5tbRuZyihI1ppsrb8yvRFHl7Cp/ol7pCk0/v5FF/nf6CxSKHmdDbOuL7SYM+tAdDfQpU+dw6rwJBnDh+HZLEllwQQrnpHAzc26/f5ux8P4b", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    TransformColumn = Table.TransformColumns(Source,{"Column1",each if Text.Contains(_,"rate") then #table({"Client","Rate"},let a=Text.Split(_,",") in List.Transform(List.Skip(a),each {a{0},_})) else _}),
    Custom1 = Table.Combine(Table.Group(Table.Group(TransformColumn,"Column1",{"n",each _},0,(x,y)=>Byte.From(y is text)),"n",{"m",each Table.AddColumn(Table.FromPartitions("Industry",Table.ToList(Table.Skip(_),each {_{0},Table.Combine(Table.Skip(_{1})[Column1])})),"Location",(x)=>Table.FirstValue(_))},0,(x,y)=>Byte.From(Table.RowCount(y)=1))[m]),
    Custom2 = Table.SelectColumns(Custom1,{"Location","Industry","Client","Rate"})
in
    Custom2

wdx223_Daniel_0-1719290240731.png

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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 Kudoed Authors