Raphael Rafatpanah
Raphael Rafatpanah

Reputation: 19967

How to create a comma separate aggregate in Google Sheets?

Given the following data set:

https://docs.google.com/spreadsheets/d/1wr7v93CM_kWygRNHyqMWcBFvd1XXkC5SYbjLjauS4SM/edit?usp=sharing

**people**  **channel**
person1 channel1
person2 channel1
person1 channel2
person3 channel2

How could I write a QUERY (or anything else that makes sense) such that the C column shows a comma separated list of the channels that a given person is in?

For example, I'd like the following output.

**people**  **channel**
person1 channel1 channel1, channel2
person2 channel1 channel1
person1 channel2 channel1, channel2
person3 channel2 channel2

Upvotes: 0

Views: 533

Answers (1)

player0
player0

Reputation: 1

try:

=ARRAYFORMULA(REGEXREPLACE(TRIM(SPLIT(FLATTEN(QUERY(QUERY({A2:A&"×", B2:B&",", ROW(A2:A)}, 
 "select max(Col2) where Col2 <> ',' group by Col3 pivot Col1"),,9^9)), "×")), ",$", ))

enter image description here

Upvotes: 1

Related Questions