+ Reply to Thread
Results 1 to 4 of 4

Why Countif give wrong results?

  1. #1
    Registered User
    Join Date
    07-19-2009
    Location
    cairo
    MS-Off Ver
    Excel 2007
    Posts
    8

    Why Countif give wrong results?

    When I use countif for long code return wrong results, is there a limit for criteria or range length?
    Attached Files Attached Files

  2. #2
    Forum Expert BMV's Avatar
    Join Date
    01-13-2020
    Location
    St-Petersburg, Russia
    MS-Off Ver
    2013-2016
    Posts
    1,329

    Re: Why Countif give wrong results?

    Thereason is not limit but length. Countif function alwise convert value to decimal an try to find it if it's possible. Only first 15 digits is the same the others replaced to 0 - it is standard for decimal
    40742371184342724458440437 -> 40742371184342700000000000
    40732971180572724293602175 -> 40732971180572700000000000
    40012871875622724335042778 -> 40012871875622700000000000
    40952771844352724285954749 -> 40952771844352700000000000
    40802371155992724470495873 -> 40802371155992700000000000

    Yiu can use =SUMPRODUCT(--($A$2:$A$5000=A2)) be careful $A$2:$A$5000 and not A:A for performane

  3. #3
    Forum Expert avk's Avatar
    Join Date
    07-12-2007
    Location
    India
    MS-Off Ver
    Microsoft Office 2013
    Posts
    3,223

    Re: Why Countif give wrong results?

    If you try to count very long numbers (16+ digits) in a range with COUNTIF, you may see incorrect results, due to a bug in how certain functions handle long numbers, even when those numbers are stored as text. Consider the screen below. All counts in column D are incorrect —although each number in column B is unique, the count returned by COUNTIF suggests these numbers are duplicates.
    This problem is related to how Excel handles numbers. Excel can only handle 15 significant digits, and if you enter a number with more than 15 digits in Excel, you'll see the trailing digits silently converted to zero. The counting problem mentioned above arises from this limit.

    Normally, you can avoid this limit by entering long numbers as text, either by starting the number with a single quote ('999999999999999999) or by formatting the cell(s) as Text before entering. As long as you don't need to perform math operations on a number, this is a good solution, and it lets you enter extra long numbers for things like like credit card numbers and serial numbers without losing any numbers.

    However, if you try to use COUNTIF to count a number with more than 15 digits (even when stored as text) you may see unreliable results. This happens because COUNTIF internally converts the long value back to a number at some point during processing, triggering the 15 digit limit described above. Without all digits present, some numbers may be counted like duplicates when counted with COUNTIF.

    Solution
    One solution is to replace the COUNTIF formula with a formula that uses SUM or SUMPRODUCT.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    atul


    If my answer (or that of other members) has helped you, please say "Thanks" by clicking the Add Reputation button at the foot of one of their posts.

    Also: if your problem is solved, please take the time to mark your thread as SOLVED by going to the top of your first post, selecting "Thread Tools" and then "Mark thread as solved".

  4. #4
    Registered User
    Join Date
    07-19-2009
    Location
    cairo
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Why Countif give wrong results?

    Thanks for information

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Index/match giving correct results, wrong results & #N/A results...sometimes
    By mrteater in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-27-2019, 10:41 AM
  2. [SOLVED] index match give wrong cell TRIED EVERYTHING !
    By incobart in forum Excel General
    Replies: 4
    Last Post: 05-12-2018, 07:58 AM
  3. [SOLVED] Getting wrong results for frequency function and countif functions
    By KurtBliss in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-13-2015, 06:39 PM
  4. [SOLVED] Countif resulting in wrong results
    By Krameht in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-27-2015, 03:51 PM
  5. Retrieving results and FORECAST function - the results are wrong!
    By Lucky_G in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 10-03-2014, 10:57 AM
  6. COUNTIF giving wrong results
    By Excel_vba in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-29-2013, 04:17 PM
  7. Countif results wrong
    By Markshr in forum Excel General
    Replies: 5
    Last Post: 02-08-2012, 02:56 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1