Countif/Sumproduct/Sumif all returning 0

Macrobiotic Brown

Board Regular
Joined
Nov 22, 2007
Messages
58
Hello all ... this is one of those "I'm going to throw my PC out the window in a minute if it doesn't do what I want it to" problems ... so I'm hoping I haven't missed anything too obvious.

I'm trying to count the occurences of conditions in two columns.

=COUNTIF([CCBUSE.xls]Sheet1!$G:$G,$X$74) returns a value of 540, and =COUNTIF([CCBUSE.xls]Sheet1!$L:$L,U76) returns a value of 2 - so that tells me that the formats etc. are working OK - but trying to combine the formula always produces a result of 0. I can confirm that there are definitely matches in the CCBUSE.xls workbook where both conditions are met in one row.

I've tried these:

{=(COUNT(IF(([CCBUSE.xls]Sheet1!$L$2:$L$2000=U76)*([CCBUSE.xls]Sheet1!$G$2:$G$2000=$X$74),[CCBUSE.xls]Sheet1!$L$2:$L$2000)))}

{=SUMPRODUCT(--([CCBUSE.xls]Sheet1!$L$2:$L$2000=U76),--([CCBUSE.xls]Sheet1!$G$2:$G$2000=$X$74))}

{=SUM(IF([CCBUSE.xls]Sheet1!$L$2:$L$2000=U76,IF([CCBUSE.xls]Sheet1!$G$2:$G$2000=$X$74,1,0)))}

Can someone please tell me what I've missed? If it makes a difference, X74 is a text field while U76 is a number field.

Thanks!!
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Are you sure that there aren't any errors in the data? that could be the problem. Also, the SUMPRODUCT function shouldn't be an array function so no {}'s.
 
Upvote 0
The first thing I saw is I don't think you need the curly brackets for the sumproduct version, though I could be wrong.
 
Upvote 0
Are you sure that there aren't any errors in the data? that could be the problem. Also, the SUMPRODUCT function shouldn't be an array function so no {}'s.
Hi Seti - what types of errors would I be looking for? I thought that by getting a correct result from the first two COUNTIF formulas that I could rule out any data errors.

Removing the {} from the SUMPRODUCT formula didn't produce the right result either.
 
Upvote 0
Look for #VALUE or #N/A errors. COUNTIF will ignore these types of errors.
 
Upvote 0
You say you get a zero result, so that probably rules out #VALUE! or #N/A as those would give an error not zero.

Are you sure that zero isn't a legitimate result? If there are only 2 matches for U76 then the formula can only return 2 at the most. Do you have any rows where both conditions are satisfied?

Another possibility is that column L is text formatted. COUNTIF will count both text and numeric values even if the criteria is numeric, SUMPRODUCT won't. Does this give you a value other than zero?

=SUMPRODUCT(--([CCBUSE.xls]Sheet1!$L$2:$L$2000=U76&""),--([CCBUSE.xls]Sheet1!$G$2:$G$2000=$X$74))
 
Upvote 0
Another possibility is that column L is text formatted. COUNTIF will count both text and numeric values even if the criteria is numeric, SUMPRODUCT won't. Does this give you a value other than zero?

=SUMPRODUCT(--([CCBUSE.xls]Sheet1!$L$2:$L$2000=U76&""),--([CCBUSE.xls]Sheet1!$G$2:$G$2000=$X$74))
Hooray! This formula is giving me the right results. Thanks Barry! :LOL:

How did the &"" bit change the result though? Is that a formatting change?
 
Upvote 0
How did the &"" bit change the result though? Is that a formatting change?

Yes, concatenating the number in U76 with "" converts it to a text value. Long term it might be best to convert column L to numbers and use your original formula

To convert column L try this

Select that column and use

Data > Text to columns > Finish
 
Upvote 0

Forum statistics

Threads
1,213,527
Messages
6,114,144
Members
448,552
Latest member
WORKINGWITHNOLEADER

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