Search code examples
google-sheetssumgoogle-sheets-formulagoogle-query-language

How to get count of different row combinations based on multiple column values?


How to print out amount of different kind of product variations?

There is dropdown menu for ColumnB having values: Red,Blue,Green
There is dropdown menu for ColumnC having values: square, circle
ColumnD is count

Amount of rows can be e.g. 200 to that matter

For the example output information should be:
Red square 7
Red circle 3
Blue square 5

ColumnA       | ColumnB       | ColumnC       | ColumnD  
-------------------------------------------------------  
Customer name | Product color | Product shape | Count  
-------------------------------------------------------  
John Doe      | Red           | square        | 2  
John Doe      | Red           | circle        | 3  
Mary Doe      | Blue          | square        | 5  
Mary Doe      | Red           | square        | 5  

Solution

  • try:

    =ARRAYFORMULA(QUERY({B:B&" "&C:C, D:D}, 
     "select Col1,sum(Col2) 
      where Col2 is not null 
      group by Col1 
      label sum(Col2)''"))
    

    enter image description here

    enter image description here