Sumproduct returning "0"

meileetan

Board Regular
Joined
Aug 18, 2005
Messages
86
Hello,
I am using Excel 2007.
In cells A1: A3, I have the values A, B, C.
In cells B1:B3, I have the values 1, 2, 1.

I want to count the number of cells in column A where its corresponding value in column B=1. The expected answer should be 2.

I tried 2 formulas:
1. =sumproduct(--(A1:A3),(B1:B3=1))
Result = #VALUE!

2. =sumproduct(A1:A3,B1:B3=1)
Result = 0

Can you please tell me where I've gone wrong?

Melissa
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Try:

=SUMPRODUCT(--(A1:A3="B"),(B1:B3=1))

which returns zero because you only have one B and its corresponding value is 2 not 1. To count the number of cells in column B that contain 1:

=SUMPRODUCT(--(B1:B3=1))

or:

=COUNTIF(B1:B3,1)

both of which return 2.
 
Last edited:
Upvote 0
Try:
Code:
=SUMPRODUCT(--NOT(ISBLANK(A1:A3)),--(B1:B3=1))
 
Upvote 0
Thanks Andrew. Indeed the countif formula is what I need.
However, could you also explain why my sumproduct formula is behaving as I had described? Just trying to make sense of sumproduct.
 
Upvote 0
Your formula:
Rich (BB code):
=sumproduct(--(A1:A3),(B1:B3=1))
Where I have highlighted red, is not returning a TRUE or FALSE argument, for the double -- to convert into a number that can be multiplied by evaluating if (B1:B3=1), which also is not being converted into a number because now you're missing the double --

The formula Andrew provided:
Rich (BB code):
=SUMPRODUCT(--(A1:A3="B"),(B1:B3=1))
And the one I provided
Rich (BB code):
=SUMPRODUCT(--NOT(ISBLANK(A1:A3)),--(B1:B3=1))
Both provide TRUE or FALSE conditions for both arguments, which you then evaluate with double unary to convert into a 1 or 0, i.e. numeric values which can then be used within the SUMPRODUCT to provide a numeric answer
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,248
Members
452,900
Latest member
LisaGo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top