countifs blank zeros.

cud22

New Member
Joined
Jan 25, 2010
Messages
24
Have spent the last two hours losing the plot trying to find why a countifs is returning unexpected result, then discovered that countifs treats blanks and zeros the same...

One of the columns i am using in the countifs has both blanks and zeros that i need to differentiate. How would you do this?

Unfortunately I do not have control over the data, and simply amending the data to fix wont work as the data will be constantly reloaded....

Example column in a1
[TABLE="class: grid, width: 74"]
<colgroup><col></colgroup><tbody>[TR]
[TD]Data[/TD]
[/TR]
[TR]
[TD] [/TD]
[/TR]
[TR]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD] [/TD]
[/TR]
[TR]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[/TR]
</tbody>[/TABLE]

Calculation example in c1

[TABLE="class: grid, width: 499"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD]Countifs Criteria[/TD]
[TD]Result[/TD]
[TD][/TD]
[/TR]
[TR]
[TD] [/TD]
[TD="align: right"]2[/TD]
[TD]=COUNTIFS(Sheet1!$A$4:$A$13,Sheet1!$C4)[/TD]
[/TR]
[TR]
[TD="align: right"]0[/TD]
[TD="align: right"]2[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD="align: right"]2[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: right"]2[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD="align: right"]2[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]99[/TD]
[TD="align: right"]0[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Changing a zero to 99 in the data table reduces the result of the countifs formula for both blank and zero, how can i avoid this?

PS, this is just an example table, in the original spreadsheet the countifs is looking at 4 fields, one of which contains blanks, zero's and positive integers; all others contain text and blanks.
 

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.
With "Data" in A1 and "Countifs criteria" in C1

Use this formula instead

=SUMPRODUCT((A$2:A$11=C2)*(LEN(A$2:A$11)=LEN(C2)))
 
Upvote 0
Thanks,that works as expected.

Was going round in circles finding the error in my formula / data before realising there was no error and the countifs formula was working as designed (but not as expected by me....!
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,318
Members
452,634
Latest member
cpostell

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