Forum Discussion
StefanoP
3 years agoRegular Visitor
Merge Rows into one row parsing two columns
Hello there, hope this is not a redundant thread. As in picture, I got a table where are stored users for certain applications and their roles. It could be reaaally nice to have one row for every...
ronrsnfld
3 years agoSuper User
- Group by SYSTEM and USER
- Aggregate into a List of Roles
- Expand the list into new columns
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKq4sNlTSUSotLgJRRfk5qQqGSrE6WCWMcEkY45IwwSVhikvCDE3CCMNVRqg6gOKxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [SYSTEM = _t, USER = _t, ROLE = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"SYSTEM", type text}, {"USER", type text}, {"ROLE", type text}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"SYSTEM", "USER"}, {
{"Role Count", each Table.RowCount(_)},
{"ROLE", each [ROLE]}}),
#"Number of Roles" = List.Max(#"Grouped Rows"[Role Count]),
#"Removed Columns" = Table.RemoveColumns(#"Grouped Rows",{"Role Count"}),
#"Extracted Values" = Table.TransformColumns(#"Removed Columns",
{"ROLE", each Text.Combine(List.Transform(_, Text.From), ";"), type text}),
#"Split Column by Delimiter" = Table.SplitColumn(#"Extracted Values", "ROLE",
Splitter.SplitTextByDelimiter(";", QuoteStyle.Csv), #"Number of Roles")
in
#"Split Column by Delimiter"