Forum Discussion

Cramos's avatar
Cramos
Frequent Visitor
9 years ago
Solved

Agroup and concatenate column with a common value

Hi!   Sorry, this has probably been asked before but I have not been able to find it.   I have to columns, column 1 have repeated values and column 2 unique values. I would like to agrupate the r...
  • MarcelBeug's avatar
    9 years ago

    In the Query Editor, you can use the Group By option.

    First choose some aggregation for column 2 to create base code, e.g. Sum:

     

     

    (ignore any errors) and adjust the generated code to:

     

    let
        Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}}),
        #"Grouped Rows" = Table.Group(#"Changed Type", {"Column1"}, {{"Column2 Values", each Text.Combine([Column2],","), type text}})
    in
        #"Grouped Rows"

    Notice that Column2 is typed as text.