Google Sheet Query - Group / concatenate multiple rows

Tom picture Tom · Mar 16, 2016 · Viewed 8.4k times · Source

I'm running a QUERY with a SUM and GROUP BY, but I'd like to aggregate multiple distinct values from the rows into a single row and column. I'm looking to concatenate all those values together.

Current Table:

Expected Table:

Person Widget Count
Bill Red, Blue, Yellow 22
Sarah Yellow, Orange 14

Answer

Aurielle Perlmann picture Aurielle Perlmann · Apr 9, 2016

You can use the filter and join functions to help:

To get a unique list of names:

=UNIQUE(A3:A)

To join the widgets:

=join(",",filter(B:B,A:A=E3))

To sum the values:

=sum(filter(C:C,A:A=E3))

enter image description here