0

I have 3 tables. Table1 is a list of items w/ a sum attached to them.

Table 2 is a list of "official items" and a category.

Table 3 is a category that needs a sum.

i.e.

Table 1

A. B
Parrot. 3
Dog. 5
Cat. 2
lizard. 1
Newt. 1
Snake. 3
Chicken. 1
Frog. 1

Table 2

A. B
Parrot. Bird
Chicken. Bird
Cat. Mammal
Dog. Mammal
Snake. Reptile
Lizard Reptile

Table3

A. B
Birds. 4
Mammals. 7
Reptiles. 4
Other. 2

I've learned that I can use an array w/ SUMIFS and IF Table2 B is Bird/Mammal/Reptiles to output those.

EDIT: the formula I'm using for table3 is =SUM(SUMIFS('Table1'!B:B,'Table1'!A:A, IF(Table2!B:B="Mammal",Table2!A:A)))

I am open to another formula if it makes life easier to achieve all 4 outcomes. Thanks!

What I am struggling with is how do I do the inverse. If none of the items in table2 match how do I sum them in other. Table1 is set to adjust depending on the answers given, so I need to ensure that the sum will compared table2 against table1 and then sum all of those on table1 that are not in table2 as other.

2
  • Hi and welcome to Superuser 👋🏻. I think it will be very useful if you edit your question and include your current formula ("I can use an array w/ SUMIFS and IF Table2 B is Bird/Mammal/Reptiles to output those") Commented Jun 26, 2023 at 4:06
  • updated with my edit. Thanks for mentioning that.
    – plzwork
    Commented Jun 28, 2023 at 0:57

1 Answer 1

0

If I understand it correctly, you only need the formula for B4 in Table 3 to calculate the sum of the rest of the animals that aren't in any category.

Why not simply subtract the sum of all the categories from the total sum of Table 1? Like this:

=SUM(Table1!B:B)-SUM(C1:C3)

If you want it rather in in one formula to be used for all rows in Table 3 you can try something like this (but I find it to be slow):
=IF(A1="Other.",SUMPRODUCT((COUNTIF(Table2!A:A, Table1!A:A)=0) * Table1!B:B),SUM(SUMIFS(Table1!B:B,Table1!A:A,IF(Table2!B:B=A1,Table2!A:A))))

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .