Having the following sheet “Animals”, how do I get an inventory of number of Birds and Mammals?:
| | A | B |
| - | ------- | --- |
| 1 | Animal | Qty |
| 2 | Chicken | 5 |
| 3 | Duck | 2 |
| 4 | Pig | 7 |
| 5 | Horse | 4 |
considering the sheet “Classes” matches each animal to a class:
| | A | B |
| - | ------- | ------ |
| 1 | Animal | Class |
| 2 | Chicken | Bird |
| 3 | Duck | Bird |
| 4 | Pig | Mammal |
| 5 | Horse | Mammal |
The sheet “Inventory” would be like this.
What formula I can fill each cell in column B with, that counts the number of animals by class?
| | A | B |
| - | ------ | --- |
| | Class | Qty |
| 1 | Bird | =(7) |
| 2 | Mammal | =(11) |
I thought about SUMIF like in =SUMIF(Animals!B:B, condition)
, but I cannot seemingly combine VLOOKUP in condition
, like in "=VLOOKUP(Animals!A2, Classes!A:B, 2, FALSE)"
. I am not one bit familiar with array formulas, if that is what one would need to do.
I checked other similar questions, in Stack Overflow and others, but the ones I found, seem to have a condition that checks against specific values instead of a formula.