问题
The Data:
ACCOUNT DESC
Gallup 1
Gallup 2
Phoenix 2
Red Rock 1
Red Rock 2
Albuquerque 1
The desired output:
ACCOUNT DESC
Gallup 1,2
Phoenix 2
Red Rock 1,2
Albuquerque 1
but in a general scope as this is a small subset (Many other accounts, 100+)
Is there a way to remove duplicate values of "ACCOUNT" and to concatenate values from the removed duplicates where the "ACCOUNT" matched?? (this method is the preferred approach desired if possible)
回答1:
Right click Account column, Group By
use New Column name : Data, Operation: All Rows,
Add Column, Custom Column, formula
=Table.Column([Data],"DESC")
Click on arrows at top of new column, extract value, use comma delimiter
Remove extra column
Full sample code if data was in Table1:
let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Grouped Rows" = Table.Group(Source, {"ACCOUNT"}, {{"Data", each _, type table}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.Column([Data],"DESC")),
#"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Custom", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
#"Removed Columns" = Table.RemoveColumns(#"Extracted Values",{"Data"})
in #"Removed Columns"
来源:https://stackoverflow.com/questions/62268926/how-to-remove-duplicate-values-in-one-column-and-concatenate-values-from-another