Home » excel » Summing costs of cell depending on the values in three other cells – Excel

# Summing costs of cell depending on the values in three other cells – Excel

Posted by: admin May 14, 2020 Leave a comment

Questions:

I’m trying to calculate the costs of purchased items for each business for every month. The problem I’m experiencing is that it will sum the whole of column `B`. This is my current formula: `=SUMPRODUCT(C:C)+(COUNTIFS(G5,A:A))`. This `Qty` is a negative number as they are being removed from the store room and then charged to the business.

Below is my current table I am working with: Any help with this much appreciated!

How to&Answers:

You could just use a pivot table. However, I generally dislike them as I prefer to have more control over them than what Excel gives me.

There is no need to use SUMPRODUCT. SUMIFS is the formula you are looking for:

``````=SUMIFS(\$C:\$C,\$D:\$D,\$F5,\$A:\$A,G\$4)
`````` I’d suggest not using whole column references, but if it’s only a small workbook, it shouldn’t cause too much slow down.

I would suggest converting your data to an excel table. You can then refer to the data by column name.

### Answer：

If I understand you want to sum the cost for each Business unit for each month. This formula should work with slight adjustment on your part (since I can’t see your columns/rows). ``````=SUMPRODUCT((\$A\$2:\$A\$50=G\$2)*(\$D\$2:\$D\$50=\$F3)*(\$C\$2:\$C\$50*\$B\$2:\$B\$50))

- or if column "C" is the total

=SUMPRODUCT((\$A\$2:\$A\$50=G\$2)*(\$D\$2:\$D\$50=\$F3)*(\$C\$2:\$C\$50))
``````

Change `G2`to your month criteria

Change `F3`to your business criteria

And change your ranges accordingly

To break this down:

``````(A2:A50=G2) - Gets the cells that match the month criteria
(D2:D50=F3) - Gets the cells that match the business criteria
(C2:C50*B2:B50) - Multiply the Qty * Cost
``````