I have two spreadsheets, one named "Expenses" and one named "Supplies".
The Expenses sheet contains the following columns: category, item, # per unit, quantity, cost. This sheet contains a log of all purchased items and contains duplicate values in the "item" column.
The Supplies sheet contains the following columns: category, item, in stock. This sheet only contains unique values in the "item" column.
I am trying to calculate the value of the "in stock" column on the Supplies sheet by summing together the product of "# per unit" and "quantity" for each instance that an item is listed.
For example, if I have the following table in the Expenses sheet:
yarn, red, 2, 3, $5
yarn, blue, 1, 4, $2
buttons, black, 2, 12, $3
yarn, blue, 3, 3, $18
Then the resulting Supplies sheet should looks like this:
yarn, red, 6
yarn, blue, 13
buttons, black, 24
I've managed to get partway there. I've written this function:
=SUMPRODUCT(INDEX('Expenses'!$C$2:$C,MATCH(B2,'Expenses'!$B$2:$B,0)),INDEX('Expenses'!$D$2:$D,MATCH(B2,'Expenses'!$B$2:$B,0)))
but it does not take duplicate values into account; it only returns the product for the first row that matches the item name criteria in the Expenses sheet.
How can I alter my formula to work for ALL rows in Expenses that match the item name?
FILTER()instead ofINDEX/MATCH.