Forum Discussion
Power Query - How to use the values in one field as column headers
- 2 years ago
Hi MichaelF1 ,
In this case you will need to use the "Pivot Column" option on the Country Column and selecting as "Values Column" the Column Measure:
This will be the result:
Here is the code of my implementation in PowerQuery:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMlTSUXJ3AhKGZkqxOnAhtyAgYWSMLOTnDlIFFzKCabREFgHrMzZCFgLrMzKBCRnD9BmZIgtBNBogC0EsNFeKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Year = _t, Country = _t, Measure = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Measure", Int64.Type}}), #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[Country]), "Country", "Measure", List.Sum) in #"Pivoted Column"Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudo 👍
Thanks!
You can also check out my LinkedIn!
Best regards,
Jorge Pessoa
Hi MichaelF1 ,
In this case you will need to use the "Pivot Column" option on the Country Column and selecting as "Values Column" the Column Measure:
This will be the result:
Here is the code of my implementation in PowerQuery:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMlTSUXJ3AhKGZkqxOnAhtyAgYWSMLOTnDlIFFzKCabREFgHrMzZCFgLrMzKBCRnD9BmZIgtBNBogC0EsNFeKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Year = _t, Country = _t, Measure = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Measure", Int64.Type}}),
#"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[Country]), "Country", "Measure", List.Sum)
in
#"Pivoted Column"
Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudo 👍
Thanks!
You can also check out my LinkedIn!
Best regards,
Jorge Pessoa