Forum Discussion
jthomas
7 years agoFrequent Visitor
How to transpose/unpivot specific columns?
Hi How to achieve the transpose shown in the image below. https://drive.google.com/open?id=1Twaq6OkR0M04caXfmYYf70RJE2Uho__M
- 7 years ago
hi, jthomas
It's pleasant that your problem has been solved, could you please mark the reply as Answered?
Best Regards,
Lin
v-lili6-msft
7 years agoCommunity Support
hi, jthomas
Based on my test, you could try these steps in Edit Queries:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fdDNCsIwDAfwVxk7K85HED1M/ES8jR1CF1wgbUYby7and/O0g/WUkP+PEFJV+bYoinyV7y/ZFSxO3c5KT4aYyW1O2Z4hvhkcKOb16hdX8RGCgpL7LW79YKQRl1jw9DD+iUfhjhq0y7SkV7s+Y0TOHghB3DS7YEMGOCspTBcNS350c6T0dQeK6JXMm0kpJFk5dOhNK4xB0U/FEiQxuSDW/QGiLfpkeof5dfUH", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ID = _t, Name = _t, Value = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Name", type text}, {"Value", type text}}),
Partition = Table.Group( #"Changed Type" , {"Name"}, {{"Partition", each Table.AddIndexColumn(_, "Index",1,1), type table}}),
#"Expanded Partition" = Table.ExpandTableColumn(Partition, "Partition", {"ID", "Value", "Index"}, {"ID", "Value", "Index"}),
#"Pivoted Column" = Table.Pivot(#"Expanded Partition", List.Distinct(#"Expanded Partition"[Name]), "Name", "Value"),
#"Filled Down" = Table.FillDown(#"Pivoted Column",{"High-Level Reason"}),
#"Removed Columns" = Table.RemoveColumns(#"Filled Down",{"Index"})
in
#"Removed Columns"
Result:
and here is pbix file, please try it.
Best Regards,
Lin
jthomas
7 years agoFrequent Visitor
Thanks Lin for the solution.
- v-lili6-msft7 years agoCommunity Support
hi, jthomas
It's pleasant that your problem has been solved, could you please mark the reply as Answered?
Best Regards,
Lin