To collect the data, use string concatenation, flatten()
and split()
in an array formula. To aggregate and pivot the data, use query()
with a pivot
clause, like this:
=arrayformula(
query(
split( flatten(E4:N & "→" & E3:N3), "→", false, false),
"select Col1, count(Col1)
where Col1 is not null
group by Col1
pivot Col2",
0
)
)
The formula above is an array formula that will create the whole result table, complete with headers, in one go.
The results look like this:
Results | Data | ||||||||
---|---|---|---|---|---|---|---|---|---|
Hamburger | Hotdog | Pizza | Pizza | Hamburger | Hotdog | Pizza | Pizza | Hotdog | |
Antony | 1 | 1 | 3 | Antony | Mia | Iva | Antony | Iva | Josh |
Derek | 1 | 3 | Derek | Antony | John | Derek | John | Mia | |
Iva | 1 | 3 | Iva | Derek | Josh | Iva | Mia | Antony | |
John | 1 | 3 | John | John | Antony | ||||
Josh | 2 | 2 | Josh | Josh | Derek | ||||
Mia | 1 | 1 | 1 |