Search code examples
google-sheetsgoogle-sheets-formulasumproduct

SUMIFS formula that can reference table array


Trying to write a formula that takes a product from one table, matches the product to a category in another table, and then sum the quantity sold of all products in that respective category. Note: MY actual data set will have much larger category tables, so I am trying to avoid any raw text in the formula (e.g. = "Apples" or "Bananas"). Here is a link to the example spreadsheet: https://docs.google.com/spreadsheets/d/103ye2hBMxDwH9fQkH9X8aRwolcVQZ7pZxOldI26UlZ4/edit#gid=0

**Table 1**
Product Quantity
Apple   5
Orange  10
Apple   10
Apple   15
Banana  20
Squash  3
Celery  4
Apple   5

**Table 2**
Food    Category
Apple   Fruit
Orange  Fruit
Banana  Fruit
Celery  Vegetable
Squash  Vegetable

***Results Table**
Category    Total Quantity
Fruit        [formula needed here]   <-- Desired output of 65
Vegetable    [formula needed here]   <--Desired output of 7

Trying different iterations of SUMPRODUCT but have been unsuccessful in matching the product in table 1 to the category in table 2


Solution

  • You may try:

    =sumifs(B:B,index(xlookup(A:A,D:D,E:E,)),G2)
    

    enter image description here