Forum Discussion
Transpose Multiple values column with unique valued column
- 4 years ago
Here's one way to do it in the query editor. To see how it works, just create a blank query, open the Advanced Editor and replace the text there with the M code below. Note that it may be better to leave the data split out into rows and generate your list of names in a measure with CONCATENATEX().
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8spPVdJRctRxUorVAfEy8oBcJx1nMNc3sagSyHXWcVGKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Project = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Project", type text}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Project2", each Text.Split([Project], ",")), #"Expanded Project2" = Table.ExpandListColumn(#"Added Custom", "Project2"), #"Removed Columns" = Table.RemoveColumns(#"Expanded Project2",{"Project"}), #"Grouped Rows" = Table.Group(#"Removed Columns", {"Project2"}, {{"People", each Text.Combine([Name], ", "), type text}}), #"Renamed Columns" = Table.RenameColumns(#"Grouped Rows",{{"Project2", "Project"}}), #"Changed Type1" = Table.TransformColumnTypes(#"Renamed Columns",{{"Project", type text}}) in #"Changed Type1"Pat
Here's one way to do it in the query editor. To see how it works, just create a blank query, open the Advanced Editor and replace the text there with the M code below. Note that it may be better to leave the data split out into rows and generate your list of names in a measure with CONCATENATEX().
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8spPVdJRctRxUorVAfEy8oBcJx1nMNc3sagSyHXWcVGKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Project = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Project", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Project2", each Text.Split([Project], ",")),
#"Expanded Project2" = Table.ExpandListColumn(#"Added Custom", "Project2"),
#"Removed Columns" = Table.RemoveColumns(#"Expanded Project2",{"Project"}),
#"Grouped Rows" = Table.Group(#"Removed Columns", {"Project2"}, {{"People", each Text.Combine([Name], ", "), type text}}),
#"Renamed Columns" = Table.RenameColumns(#"Grouped Rows",{{"Project2", "Project"}}),
#"Changed Type1" = Table.TransformColumnTypes(#"Renamed Columns",{{"Project", type text}})
in
#"Changed Type1"
Pat
- JosephKim4 years agoNew Member
Thank you so mucn, mahoneypat At first, I troubled with applying the script, but eventually I was able to edit it to work it out as you have guided. One question would be how to transform to unique value column for the project list? I really appreciate your help!