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

2 Answers 2


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

Try this:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.