Skip to main content
add table
Source Link
doubleunary
  • 15.7k
  • 9
  • 23
  • 59

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:

ResultsData
HamburgerHotdogPizzaPizzaHamburgerHotdogPizzaPizzaHotdog
Antony113AntonyMiaIvaAntonyIvaJosh
Derek13DerekAntonyJohnDerekJohnMia
Iva13IvaDerekJoshIvaMiaAntony
John13JohnJohnAntony
Josh22JoshJoshDerek
Mia111

See query(), split() and flatten().

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 
  ) 
)

See query(), split() and flatten().

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:

ResultsData
HamburgerHotdogPizzaPizzaHamburgerHotdogPizzaPizzaHotdog
Antony113AntonyMiaIvaAntonyIvaJosh
Derek13DerekAntonyJohnDerekJohnMia
Iva13IvaDerekJoshIvaMiaAntony
John13JohnJohnAntony
Josh22JoshJoshDerek
Mia111

See query(), split() and flatten().

Source Link
doubleunary
  • 15.7k
  • 9
  • 23
  • 59

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 
  ) 
)

See query(), split() and flatten().