Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Countif function giving incorrect answer

5,132 views
Skip to first unread message

Anthony

unread,
Apr 7, 2010, 9:40:13 PM4/7/10
to
I have a weird issue where the Countif function is incorrectly giving
a result of 1, when the expected result is zero.

Cells A1:A3 are formatted as Text, and they have the following entered
in them:
A1 149902
A2 186427
A3 1541477

Cells B1:B3 are also formatted as text, and the have the following
entered in them:
B1 6-6120
B2 6-2310
B3 6-2410

In cell C1, i entered the following formula and filled down to C3:
=COUNTIF($A$1:$A$3,B1)

For every result in C1:C3, it is returning 1, even though i know that
the numbers in column B dont exist in column A and it should return
zero for each answer!

If you look at just the formula in C1, it thinks that it has found B1
(6-6120) in the value of A3 (1541477)
If i change A3 up or down by 1 (i.e 1541476 or 1541478), then the C1
formula returns 0: change it back to the orginal value, and it retruns
1?. The same happens for the other numbers as well. What is the
relationship between the 2 numbers for Countif to return 1?

Is there any explanation why this is occurring?

T. Valko

unread,
Apr 7, 2010, 10:05:15 PM4/7/10
to
>Is there any explanation why this is occurring?

COUNTIF evaluates text numbers and numeric numbers as being equal.

To see why you're getting those results do this...

Make sure cells A5:A7 are formatted as General.
*Manually* enter the numbers from A1:A3 in the cells A5:A7. *Do not* just
copy/paste the cells because you'll also be copying the TEXT format.

Now, format the cells A5:A7 as Date.
Compare those dates to the entries in cells B1:B3.

COUNTIF is evaluating cells B1:B3 as dates, which in Excel are really just
numbers formatted to look like dates, and the values in cells A1:A3 just
happen to be the date serial numbers of the entries in B1:B3.

Solution:

Use SUMPRODUCT:

=SUMPRODUCT(--(A$1:A$3=B1))

--
Biff
Microsoft Excel MVP


"Anthony" <anthony...@hillpda.com> wrote in message
news:3d9fccaa-857a-475e...@s9g2000yqa.googlegroups.com...

ozgrid.com

unread,
Apr 7, 2010, 10:05:47 PM4/7/10
to
You should always avoid Text format unless you really do have text. Format
as number and for your B1:B3 values custom format like: 0-0000

--
Regards
Dave Hawley
www.ozgrid.com


"Anthony" <anthony...@hillpda.com> wrote in message
news:3d9fccaa-857a-475e...@s9g2000yqa.googlegroups.com...

Ron Rosenfeld

unread,
Apr 7, 2010, 10:12:09 PM4/7/10
to
On Wed, 7 Apr 2010 18:40:13 -0700 (PDT), Anthony <anthony...@hillpda.com>
wrote:

I would classify this as a bug.

The values in column B, even though formatted as TEXT, (and ISTEXT(B1)-->TRUE),
are apparently being interpreted as DATES by the COUNTIF function. And Excel
stores June 1, 6120 as 1541477 (number of days since 1/1/1900).

The same is occurring with the other entries.

Note that if you change to the 1904 date system, the COUNTIF formula will
return zero's.

=SUMPRODUCT(--($A$1:$A$3=B1)) returns the correct answer, so there is clearly
and inconsistency.

--ron

ozgrid.com

unread,
Apr 7, 2010, 10:22:09 PM4/7/10
to
Should have said enter 6-6120 as 66120 in a cell PRE custom formatted as:
0-0000


--
Regards
Dave Hawley
www.ozgrid.com

"ozgrid.com" <da...@ozgrid.com> wrote in message
news:eZXHOAs...@TK2MSFTNGP05.phx.gbl...

Dave Peterson

unread,
Apr 8, 2010, 8:02:20 AM4/8/10
to
Just to add to Biff's excellent response...

If you switch to the 1904 date (tools|options|calculation tab in xl2003 menus),
then the formulas evaluate to 0's.

--

Dave Peterson

Spencer Antonia

unread,
Oct 10, 2023, 2:04:39 AM10/10/23
to
ในยุคที่เทคโนโลยีมีบทบาทสำคัญในชีวิตประจำวันของเรา การพบกับเว็บไซต์สล็อตออนไลน์เว็บใหม่ที่เปิดให้บริการตลอด 24 ชั่วโมงเป็นเรื่องที่น่าตื่นเต้นและน่าสนุกอย่างยิ่ง วันนี้เราจะพาคุณไปสำรวจโลกของ wo365 cc pg slot เว็บตรง ที่มีสล็อตแจกเครดิตฟรีและเป็นเว็บใหม่ที่คุณอาจจะสนุกไปกับการเล่นสล็อตออนไลน์ได้ตลอด 24 ชั่วโมงที่นี่!
✅ เข้าเว็บไซต์

หากคุณต้องการตรวจสอบเว็บไซต์ wo365 cc pg slot ไปที่:http://bit.ly/3RPBnb1

✅ สมัครสมาชิก

หากคุณต้องการเป็นสมาชิกและเริ่มต้นการเล่น สามารถสมัครได้ที่:http://bit.ly/3RPBnb1

✅ ติดต่อเรา

หากคุณมีคำถามหรือข้อสงสัยเกี่ยวกับเว็บไซต์ สามารถติดต่อทีมงานได้ที่:http://bit.ly/3RPBnb1

✅ รับโปรโมชั่น

ท่านสามารถรับโปรโมชั่นต่างๆ ได้ที่:http://bit.ly/3RPBnb1

สล็อตแจกเครดิตฟรี เว็บใหม่ที่ให้บริการตลอด 24 ชั่วโมง

สำหรับผู้ที่หลงไหลในโลกของเกมสล็อตออนไลน์ วันนี้คุณมีโอกาสพบกับ wo365 cc pg slot เว็บตรง ที่เปิดให้บริการตลอด 24 ชั่วโมงเพื่อให้คุณได้สนุกกับการเล่นสล็อตออนไลน์อย่างไม่มีข้อจำกัดเวลา

คุณไม่ต้องกังวลเรื่องการเงินและความน่าเชื่อถือ เนื่องจาก wo365 cc pg slot มีระบบการฝากเงินและถอนเงินที่ปลอดภัย และทำรายการอย่างรวดเร็ว ทำให้คุณสามารถเริ่มเล่นเกมสล็อตโปรดของคุณได้ทันที

ไม่ว่าคุณจะชื่นชอบสล็อตแบบไหน ที่ wo365 cc pg slot เว็บตรง คุณสามารถเลือกเล่นได้ตามใจต้องการ เพราะที่นี่มีเกมสล็อตมากถึง 300 เกมให้คุณเลือกเล่น ทั้งสล็อตแบบไม่ผ่านเอเยนต์ สล็อตทันสมัย และสล็อตที่มีแจ็คพอตใหญ่โต โดยไม่มีขั้นต่ำในการเดิมพัน

นอกจากนี้ คุณยังสามารถทดลองเล่นสล็อตฟรีโดยไม่ต้องผ่านเอเยนต์ และไม่มีขั้นต่ำในการฝากเงิน และทางเว็บยังรองรับการทำรายการผ่านทรูวอลเล็ต ทำให้คุณสามารถเล่นสล็อตออนไลน์ได้เงินจริงและถอนเงินได้โดยไม่มีขั้นต่ำ

ไม่ว่าคุณจะเป็นผู้เล่นมือใหม่หรือผู้เล่นที่มีประสบการณ์ในการเล่นเกมสล็อตมากมาย คุณก็สามารถเข้ามาท

0 new messages