Google Sheets – How to Count Items Meeting Criteria in Multiple Columns

google sheetsgoogle-sheets-query

In Google Spreadsheets I need to count instances of a certain value but only when they match either of two values in another column. So below I would ask for the count of all brown animals that are either Mammal OR Reptile, and expect a value of 2.

 |  A           B           C
----------------------------------
1|  Animal      Type        Colour
----------------------------------
2|  Dog         Mammal      Yellow
3|  Cat         Mammal      Brown
4|  Lizard      Reptile     Brown
5|  Snake       Reptile     Yellow
6|  Alligator   Reptile     White
7|  Dove        Bird        White
8|  Chicken     Bird        Brown

Best Answer

Use the following formula to accomplish that:

=QUERY(C1:E8, "SELECT COUNT(C) WHERE (D='Mammal' OR D='Reptile') AND E='Brown' LABEL COUNT(C) ''")