To add a condition to SUMPRODUCT, include the test as an extra array: =SUMPRODUCT(--(C7:C19=C2),E7:E19,F7:F19) multiplies units by weight per unit, but only for the rows where the product matches the value in C2. The condition returns TRUE/FALSE, the double minus converts those to 1s and 0s, and multiplying by zero cancels out every row that doesn’t qualify.
For two conditions, multiply them together — =SUMPRODUCT((C7:C19=C2)*(B7:B19=B2)*E7:E19*F7:F19) — which is AND logic. For OR logic, add them instead and cap at 1 so overlapping matches aren’t counted twice: =SUMPRODUCT(((C7:C19=C2)+(C7:C19=C3)>0)*E7:E19).
One thing to watch: every array must be the same size or you get #VALUE!, and text or blank cells inside a numeric range will also throw that error when multiplied — wrap them in N() or clean the data first.
SUMPRODUCT is one of the most important Excel functions. The best part about it is that you can modify it in several ways.
And one of its powers which I have discovered recently is: using it as SUMPRODUCT IF. In short, a Conditional SUMPRODUCT.
Well, as you know, you can use SUMPRODUCT to multiply and sum specified ranges or arrays. With a conditional SUMPRODUCT, you can multiply and sum only the values that meet the criteria.
Yes, you heard it right. And you know the best part? There is no need to use the IF function for this. Isn’t it awesome?
Yes?
So today in this post, I’d like to share with you a problem and a simple way to use SUMPRODUCT IF to solve it.
So be with me to learn one of the most amazing Excel formulas and make sure to download sample files.
How I Got to Know About this Conditional SUMPRODUCT
First things first.
Yesterday, I got a mail from one of my subscribers. She wanted to create a conditional statement with SUMPRODUCT and IF to get data from a table.
Here is the mail which I have received:
“Hey Puneet, I need your help. Is there any way to combine SUMPRODUCT IF? I have some data in a table, and I want to get the product of two columns meeting criteria. Please help me out.”
Along with the mail, I got an Excel file from her with the following components. You can download this file from here to follow along.

- Stock Data: This table is stock data that is stored in different stores of her company. It has the product name, units in stock, and weight per unit.
- Drop-Down List: A drop-down menu to select a product.
From this table, she wanted to get the total quantity of a product (units * weight per unit) by selecting the dropdown. For example, if she selects “Pulses”, the cell should show the total quantity of Pulses, which is the units multiplied by the weight per unit for each Pulses row, added together.
Please note that the product name is the condition here.

Solution with SUMPRODUCT IF
At that time, I was sure about one thing: to get the sum of the products of arrays or ranges, we can use SUMPRODUCT.
But here, the game was to get the sum by multiplying the units and the weight per unit only for the rows that meet the criteria.
And the formula we can use is:
=SUMPRODUCT(--(C7:C19=C2),E7:E19,F7:F19)

Now, when you select an entry from the drop-down list, this formula only adds up the products for the rows that meet the criteria.
Hey, wait for a minute: Just like this formula, I have listed a few more smart formulas which can amaze you.
How It Works
As you already know, SUMPRODUCT can work with arrays. So in the above formula, we have used three arrays to get the product of values.

The formula works in the following way.
1. Creating a Condition
First, we have an array to check the condition of the product name. It will check the values in the product column and return TRUE for the matched values and FALSE for the others.

2. Using Double Minus Sign
Now, the next thing is to convert TRUE-FALSE values into 1-0 so that we can use them in the calculation. And for this, we have used the double minus sign before the first array.

3. Multiplying Arrays
After converting TRUE-FALSE into 1-0, the array will look something like this. Here, for all the values where the criteria are not met, we have zeros.

Remember, anything multiplied by zero is zero. In this way, we get the product only for those rows where we have 1. In short, where the condition is met.
The comparison isn’t case-sensitive, so “pulses” and “Pulses” both match. And as long as you pass the ranges as separate arguments (with commas), SUMPRODUCT treats text in the number columns as 0.
SUMPRODUCT IF with Multiple Conditions
To add a second condition (AND logic), multiply the two conditions. Let’s say column D has the store name and you only want the product in C2 from store “A”:
=SUMPRODUCT((C7:C19=C2)*(D7:D19="A"),E7:E19,F7:F19)
A row counts only when both conditions are TRUE, as TRUE * TRUE is 1 and anything with a FALSE is 0. You can use a number condition in the same way, like (E7:E19>100) for the rows with more than 100 units.
For OR logic (one product or the other), add the conditions instead and test the result with >0, so a row that matches both is counted only once:
=SUMPRODUCT(--((C7:C19="Pulses")+(C7:C19="Rice")>0),E7:E19,F7:F19)
Common Errors with SUMPRODUCT IF
- #VALUE! from different range sizes: all the ranges must have the same number of rows, like C7:C19, E7:E19 and F7:F19.
- #VALUE! from text with the * sign: if you multiply the ranges with * (like E7:E19*F7:F19) and one cell has text, the formula returns #VALUE!. Pass the ranges with commas instead, and the text counts as 0.
- Result is 0: the condition doesn’t match any row, usually because of extra spaces in the product names or the drop-down value.
SUM with FILTER in Microsoft 365
In Microsoft 365 and Excel 2021 and later, you can also filter the products first and then sum them. The 0 at the end is what FILTER returns when no row matches, so you get 0 instead of the #CALC! error:
=SUM(FILTER(E7:E19*F7:F19,C7:C19=C2,0))
SUMPRODUCT still works in every version, so use it if the file is shared with people on older versions of Excel.
Conclusion
The best part about using this conditional SUMPRODUCT is you don’t need to use IF and all the calculation is in a single cell. As I said SUMPRODUCT is one of the most powerful functions and this is the best thing you can do with its powers.
Now tell me one thing.
Have you ever tried using a condition in SUMPRODUCT before?
Please share your views with me in the comment section. I’d love to hear from you and please don’t forget to share it with your friends, I am sure they will appreciate it.
Frequently Asked Questions
Why do I need the double minus in SUMPRODUCT?
When you pass a TRUE/FALSE array as its own argument, SUMPRODUCT treats it as zeros. The double minus turns TRUE into 1 and FALSE into 0, so the condition works. You don’t need it when you multiply the condition with *, as the multiplication converts it already.
Can I use SUMIFS instead of SUMPRODUCT?
Only if you add a helper column with units * weight per unit first. SUMIFS can sum one column with conditions, but it can’t multiply two columns, which is why SUMPRODUCT is handy here.
Do I need Ctrl + Shift + Enter for SUMPRODUCT?
No. SUMPRODUCT works with arrays on its own, so a plain Enter works in every version of Excel.
Thanks Puneet, this is fantastic; really helpful!
The good things are simple, very good
Thank very useful information.
Two condition lookup i have used sumproduct.
Nice work – thanks for the help on this!
Nice explanation
Hi! Can you please help with a solution to a problem I am having?
I have a table of x’s and 0’s and a column with numbers. I need to find a way to get a total for the rows where I have x’s like this: sum=numbers on the column*cells with x in them
Thank you in advance.
Could you create a further column with ‘countif (A1:X1,=”X”)’
Where ‘A1:X1’ is the first row cell references. This should give you the number of ‘X’s in the row – and then you multiply by the relevant cell in the column with numbers?
Nice explanation
Nice explanation,please can you help me to calculate with between dates
Thanks for the example. Is there away to make it even more flexible? In the example above, there is a store id unique product. I want the user to have two drop down boxes where they can select store and/or product. Is there a way build a formula to return a sum if the store or product was left blank? using sumproduct would result in a zero value is one was left blank.
What if i want to add a list in the dropdown that is “ALL”?
Excellent tips…thanks for sharing us…
I’m so glad you liked it. 🙂
Very good solution.
Thank you!
I’m so glad you liked it. 🙂
excellent!!! Really love your post
I’m so glad you liked it.
Hi Puneet!
I wish you add an option to download the PDF version of discussions for future references.
Thanks
Ahmed Sheikh
Didn’t get you, please come again.
Well I wanted you to add an option to download the PDF version of your posts/discussions for our future references as in KAWSAR’s discussions.
Thankyou
That is an awesome solution. Thank you so much for the insight and sharing the knowledge 🙂
You’re Welcome
Very helpful. I found an identical solution elsewhere on a forum, but because it was explained so poorly I didn’t think it was the solution to my problem. Thank you for explaining how this works with a working example. This is exactly what I was looking for.
I’m happy you have found this useful.
Thank You
You’re welcome. 🙂
Hi Puneet. Thanks for the use of the double negative
You’re welcome, Adrian.
The double negative can also be replaced by the N() function. Since in excel 2003 there was nothing to convert TRUE/FALSE to numbers so I used double negative. But a really cool tutorial overall!
Thank You Chandeep for improvement.
Well, I never thought I can use it.
Super awesome.
Nice Puneet
Thanks Ratanak.
Thanks
Thanks Puneet, you are really a genius