SUMPRODUCT with IF logic

In this article, we will learn about how to use IF logic with SUMPRODUCT function in Excel.

In simple words, SUMPRODUCT function take the product of the corresponding values and returns the sum of all. SUMPRODUCT function also use -- (operator) to meet certain criteria.
Syntax:

=SUMPRODUCT(--( array1=”condition”) , array2 , array3)

array1 : where criteria meet
array2 & array3 : these arrays will gets the product of corresponding values and returns their sum.

Let’s understand this function using it in an example.
315
Here the problem is we need to find the total price for the product “Carrot”.

So here we use the formula to get the total price for Carrot

=SUMPRODUCT(--(A2:A19="Carrot"), B2:B19, C2:C19)

A2:A19: checks the range A2:A19 for the text “Carrot” and returns True if finds “Carrot” or else False
-- : the operator decode True as 1 and False as 0.
B2:B19 : Quantity (range) to be multiplied with Unit Price.
C2:C19 : Unit price (range) to be multiplied with Quantity.
316

 

Product Quantity UnitPrice Price
1 33 1.77 58.41
0 87 3.49 0
0 58 1.87 0
0 82 1.87 0
0 38 2.18 0
1 54 1.77 95.58
0 149 3.49 0
1 51 1.77 90.27
1 100 1.77 177
0 28 1.35 0
0 36 2.18 0
0 31 1.87 0
0 28 3.49 0
1 44 1.77 77.88
1 23 1.77 40.71
0 27 1.35 0
0 43 2.18 0
0 123 2.84 0
539.85

As you have understood from the above snapshot and table, that SUMPRODUCT function multiplies corresponding values and returns the Sum.

1’s & 0’s in the left most column is the IF logic used in SUMPRODUCT function.
So here we use the formula for total price for Whole wheat

=SUMPRODUCT(--(A2:A19="Whole wheat"),B2:B19,C2:C19)

A2:A19: checks the range A2:A19 for the text “Whole wheat” and returns True if finds “Carrot” or else False
-- : the operator decode True as 1 and False as 0.
B2:B19 : Quantity (range) to be multiplied with Unit Price.
C2:C19 : Unit price (range) to be multiplied with Quantity.

317

 
 

Product Quantity UnitPrice Price
0 33 1.77 0
1 87 3.49 303.63
0 58 1.87 0
0 82 1.87 0
0 38 2.18 0
0 54 1.77 0
1 149 3.49 520.01
0 51 1.77 0
0 100 1.77 0
0 28 1.35 0
0 36 2.18 0
0 31 1.87 0
1 28 3.49 97.72
0 44 1.77 0
0 23 1.77 0
0 27 1.35 0
0 43 2.18 0
0 123 2.84 0
921.36

As you have understood from the above snapshot and table, that SUMPRODUCT function multiplies corresponding values and returns the Sum.

1’s & 0’s in the left most column is the IF logic used in SUMPRODUCT function.

Hope you understood how to use IF logic in SUMPRODUCT function in Excel. Explore more articles on Excel Logic_test function here. Please feel free to state your query or feedback for the above article.

Leave a Reply

Your email address will not be published. Required fields are marked *

Terms and Conditions of use

The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.

Visit Us On TwitterVisit Us On FacebookVisit Us On Google PlusVisit Us On Youtube