How to use SUMPRODUCT IF in Excel

How to use SUMPRODUCT IF in Excel

SUMPRODUCT is an extremely resourceful function with many purposes. When you are comparing data between two or more ranges and calculating with multiple criteria, The SUMPRODUCT function is your first choice. It has the unique ability to handle arrays in smart and elegant ways. Often we need to use SUMPRODUCT IF or conditional SUMPRODUCT to compare between columns with given criteria and to find the result. Today in this article, we will discuss the SUMPRODUCT IF function and some other alternative approaches to SUMPRODUCT IF function.

Download Practice Workbook

Download this practice sheet to practice the task while you are reading this article.

Excel SUMPRODUCT function

Technically, the “SUMPRODUCT” function returns the sum of the values of corresponding arrays or ranges. Normally, the default operation is multiplication, but addition, subtraction, and division can also be done.

Syntax

The syntax of the SUMPRODUCT function is simple and direct.

=SUMPRODUCT(array1, [array2], [array3], …)

Argument

  • [array1]: The first array or ranges of cells whose components you want to multiply and then add
  • [ array2], [array3]…: Array arguments 2 to 255 whose values you want to multiply and then add.

SUMPRODUCT IF Formula: 2 Types

In Excel, there is no built-in “SUMPRODUCT IF” function but you can use this as an array formula by combining the “SUMPRODUCT” and the “IF” function. Let’s discuss this formula.

1.   SUMPRODUCT IF with One Criteria

We can use the “SUMPRODUCT IF” formula with one criterion. Follow these steps to learn

Step-1:

Consider a data table where some fruit Items are given with “Region”, “Qty”, and “Price”. We will find out the total price of some items.

creating table

Step-2:

Create another table anywhere in the worksheet where you want to get the total price of the item. We choose “Cherry”, “Apple”, “Plum” items.

creating table

Step-3:

Apply the “SUMPRODUCT IF” formula in cell “H4”. The format of this formula is

=SUMPRODUCT(IF(criteria range=criteria, values range1*values range2))

Insert the values into the formula.

=SUMPRODUCT(IF($C$4:$C$20=G4,$D$4:$D$20*$E$4:$E$20))

Where,

  • Criteria_range is $C$4:$C$20.
  • The Criteria is
  • Values_range1 is $D$4:$D$20.
  • Values_range2 is $E$4:$E$20.

applying formula

Apply this formula as an array formula by pressing “CTRL+SHIFT+ENTER” simultaneously.

Getting result

Step-4:

We got our total price. Now apply the same formula for the rest of the items.

Final result

2. SUMPRODUCT IF with Multiple Criteria in Different Column

We will use the same formula for multiple criteria.

Step-1:

Let’s add another criteria “Region” in table 2. In this case, we want to find the total price of “Cherry” from the “North America” region and “Apple” from the “Asia” region.

creating table

Step-2:

Now apply the “SUMPRODUCT IF” formula. Insert the values into the formula.

=SUMPRODUCT(IF($B$4:$B$20=G4,IF($C$4:$C$20=H4,$D$4:$D$20*$E$4:$E$20)))

Where,

  • Criteria_range is $B$4:$B$20, $C$4:$C$20.
  • The Criteria is G4, H4.
  • Values_range1 is $D$4:$D$20.
  • Values_range2 is $E$4:$E$20.

Applying condition

Apply this formula by pressing “CTRL+SHIFT+ENTER” simultaneously.

Getting result

Step-3:

Our value is here. Now do the same for the “Apple” item.

final result

Alternative approaches to SUMPRODUCT IF Formula

There are some other approaches to derive the previous results. An alternative way to calculate the “SUMPRODUCT IF” formula is to insert the criteria within the “SUMPRODUCT” function as an array using double unary (–) to converts the “TRUE” or “FALSE” into “1” or “0”.

1. SUMPRODUCT If with One Condition

Step-1:

We will consider the previous example in this case. We will find the total price of “Mango” from the list.

Condition Applying

Step-2:

Apply the conditional “SUMPRODUCT” formula

The final formula is

=SUMPRODUCT(–(C4:C20=G4),D4:D20,E4:E20)

Where,

  • Array1 is (–(C4:C20=G4).
  • [Array2] is D4:D20.
  • [Array3] is E4:E20.

Applying formula

Press “Enter”. Our result is here.

final result

Explanation:

 

We will now explain how this conditional “SUMPRODUCT” function works

Step-1:

When we enter the “–(C4:C20=G4)” into the formula this double unary (–) converts the “TRUE” or “FALSE” into “1” or “0”. Select this “–(C4:C20=G4)” portion in your worksheet and press “F9” to see the underlying values.

{0,1,0,0,0,0,0,0,1,1,0,1,1,0,0,0,1}

Step-2:

Now if we break down the arrays into values the actual formula will look like this,

=SUMPRODUCT({0,1,0,0,0,0,0,0,1,1,0,1,1,0,0,0,1},{20,50,100,50,500,80,90,56,60,80,100,40,45,25,35,45,90},{15,20,2,5,12,10,15,9,20,30,5,30,25,10,10,20,15})

Step-3:

The first array will multiply with the second then the second array will multiply with the third array. Follow this picture

Array table

That is how this conditional “SUMPRODUCT” works.

2. SUMPRODUCT IF with Multiple Condition in Different Column

Step-1:

In the following example, we will find out the total price of “Cherry” from the “North America” region.

creating table

Step-2:

Apply the formula. The final form of this formula is,

=SUMPRODUCT(–(B4:B20=G4), –(C4:C20=H4),D4:D20,E4:E20)

Where,

  • Array1 is (–(C4:C20=G4),–(C4:C20=H4).
  • [Array2] is D4:D20.
  • [Array3] is E4:E20.

Applying formula

Press “Enter”. Our result is achieved.

final result

3. SUMPRODUCT IF with OR Logic

We can add “OR” logic to our formula to make this formula more dynamic.

Step-1:
Let’s say, we need to get the total price of “Mango” and “Cherry” from the data table.

creating table

Step-2:

Apply the “SUMPRODUCT” formula with “OR” and insert the values.

The formula is

=SUMPRODUCT(–((C4:C20=G4)+(C4:C20=H4)>0),D4:D20,E4:E20)

Where,

  • Array1 is –((C4:C20=G4)+(C4:C20=H4)>0). Here G4 is “Mango” and H4 is “Cherry”. This array counts the total number of “Mango” and “Cherry” in the data table.
  • [Array2] is D4:D20.
  • [Array3] is E4:E20.

getting result

Press “Enter” to get the total price of the products.

final result

4. SUMPRODUCT IF with Multiple AND/OR Criteria

In this case, we will apply Or logic with multiple conditions.

Step-1:

In the following example, we need to find the total price of “Cherry” and “Mango” from “Asia” and “Europe” regions.

creating table

Step-2:

To get the result we will now apply the formula with AND/OR logic. The formula is

=SUMPRODUCT(–((B4:B20=G4)+(B4:B20=H4)>0),–((C4:C20=I4)+(C4:C20=J4)>0),D4:D20,E4:E20)

Where,

  • Array1 is –((B4:B20=G4)+(B4:B20=H4)>0),–((C4:C20=I4)+(C4:C20=J4)>0). Here B4:B20 is “Region” Column, G4 and H4 is “Asia” and “Europe”.Similarly,C4:C20 is “Item” column, I4 and J4 is “Cherry” and “Mango”.
  • [Array2] is D4:D20.
  • [Array3] is E4:E20.

Getting result

Press “Enter” to get the total price.

final result

Quick Notes

✅Arrays in the SUMPRODUCT formula must have the same number of rows and columns. If not, you get the #VALUE! Error.

✅The “SUMPRODUCT” function treats non-numeric values as zeros. If you have any non-numeric values in your formula the answer will be “0”.

✅ Since the “SUMPRODUCT IF” formula is an array formula your need to press “CTRL+SHIFT+ENTER” simultaneously to apply the formula.

✅The “SUMPRODUCT” function does not support wildcard characters.

Conclusion

Today we discussed the “SUMPRODUCT IF” formula and some other alternative conditional “SUMPRODUCT” formula in this article. Hope this article is useful to you when you are facing problems. If you have any confusion, you are welcome to comment.

We will be happy to hear your thoughts

Leave a reply

ExcelDemy
Logo