Forum Discussion
Merge two rows into a single row
- 1 year ago
Hi,
Upload the file to Google Drive/One Drive and share the download link here.
Hi brdrok
As per my understanding of your requirement, I have tried with some demo data
Can you please try the below M code
Just copy the M-code and use from #"Split Column by Delimiter" becasuse you already have your table so from there u use the M- code
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUUqsSVKK1YlWcgKyk2tSwGyQeGpNGlw8vSYDzHYGsjNqMpViYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Key = _t, Investor = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Key", type text}, {"Investor", type text}}),
#"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Changed Type", {{"Investor", Splitter.SplitTextByDelimiter("|", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Investor"),
GroupedRows = Table.Group(#"Split Column by Delimiter", {"Key"}, {
{"investors", each _, type table [Key=nullable text, Investor=nullable text]}
}),
AddedCustom = Table.AddColumn(GroupedRows, "Investor", each Text.Combine([investors][Investor], "|")),
FinalTable = Table.SelectColumns(AddedCustom, {"Key", "Investor"})
in
FinalTable
Data I used
Result