The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hey folks,
Can you please tell me how can I have the values from the Metrics column as column headers with the values from the value column under of this new colum.
I've tried unpivot and transpose, but I'm clear missing something as I can't get this right.
Expected output from the second photo.
Thank you.
Solved! Go to Solution.
Hi, @ROG ;
You could pivot in power query. select [Metric] and [Value] column ->pivot column.
The final show:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtQ11DVS0lHy83EBkgH5xSUFiSlAln9Bal5mukJSYnEqkGdooBSrA1ZvpGusawYUcXENBZIFiZUgxc45+cWZeXDVRkiqLXWBeoHK/bwRyh3LUovSU2GqjYGqYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, #"Country Code" = _t, #"Country Category" = _t, Metric = _t, value = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Country Code", type text}, {"Country Category", type text}, {"Metric", type text}, {"value", Int64.Type}}),
#"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[Metric]), "Metric", "value")
in
#"Pivoted Column"
Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @ROG ;
You could pivot in power query. select [Metric] and [Value] column ->pivot column.
The final show:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtQ11DVS0lHy83EBkgH5xSUFiSlAln9Bal5mukJSYnEqkGdooBSrA1ZvpGusawYUcXENBZIFiZUgxc45+cWZeXDVRkiqLXWBeoHK/bwRyh3LUovSU2GqjYGqYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, #"Country Code" = _t, #"Country Category" = _t, Metric = _t, value = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Country Code", type text}, {"Country Category", type text}, {"Metric", type text}, {"value", Int64.Type}}),
#"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[Metric]), "Metric", "value")
in
#"Pivoted Column"
Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks a lot!