Forum Discussion
Merging Specific Columns of a Table
- 3 years ago
Hi Elliot137 ,
The following example query turns this:
...into this:
Example Query:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyNvFR0lEyNDU0VYrViVYyMTYyDAcJmFgagAWQVJhDBSwNXMEqLEzQBMyNlGJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Block #" = _t, #"M/C" = _t]), groupRows = Table.Group(Source, {"Block #"}, {{"M/C", each Text.Combine([#"M/C"], ", "), type nullable text}}) in groupRowsSummary:
Group By whichever columns you want to keep.
Create aggregate columns for each of the columns you want to combine using the SUM (or any statistical) operator.
Edit the resulting code in the formula bar to change List.Sum(...) to Text.Combine(..., ", ") for each of the columns to be combined.
So this:
...goes to this:
For your date column, you can just choose the MIN operator during the Group By process.
Pete
Hi Elliot137 ,
The following example query turns this:
...into this:
Example Query:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyNvFR0lEyNDU0VYrViVYyMTYyDAcJmFgagAWQVJhDBSwNXMEqLEzQBMyNlGJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Block #" = _t, #"M/C" = _t]),
groupRows = Table.Group(Source, {"Block #"}, {{"M/C", each Text.Combine([#"M/C"], ", "), type nullable text}})
in
groupRows
Summary:
Group By whichever columns you want to keep.
Create aggregate columns for each of the columns you want to combine using the SUM (or any statistical) operator.
Edit the resulting code in the formula bar to change List.Sum(...) to Text.Combine(..., ", ") for each of the columns to be combined.
So this:
...goes to this:
For your date column, you can just choose the MIN operator during the Group By process.
Pete