+ Reply to Thread
Results 1 to 9 of 9

Countif not counting duplicate values correctly

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,669

    Countif not counting duplicate values correctly

    Hi see enclosed file,

    Please open the enclosed file.

    I have 3 cols of data Num1, Num2 and Date.

    i concatenate various combinations of Num1, Num2 and Date.

    See col = ConCat_Cols_ABC.....see cell D5. If i want to find the number of duplicates for this entry "107888344610834202" see countif in col = Countif_ColD.
    it indicates that there are two entries for "107888344610834202" but if you look at col = Chk_Cnts_For_"107888344610834202" where i do an if/then.....
    the results indicate that there is only 1 entry for this value of "107888344610834202"

    i did various other attempts at trying to figure htis out by concatenating other things........from what i can tell is if i have the date in the concate ...things dont work right.

    can someone help me?
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,597

    Re: Countif not counting duplicate values correctly

    Did you mean to post in the VBA section? If not, I shall move the thread for you.

    A good sample workbook has just 10-20 rows of representative data (not 1000s!) that has been desensitised. It also has expected results mocked up, relevant cells highlighted and a few explanatory notes.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,260

    Re: Countif not counting duplicate values correctly

    Excel can only handle 15 significant figures. Your concatenated strings have 18

    So. These tow:

    107888344610834201
    107888344610834202


    are seen as being the same. So... use this instead:

    =SUMPRODUCT(--($D$2:$D$12000=D2))
    Attached Files Attached Files
    Last edited by Glenn Kennedy; 02-21-2022 at 11:06 AM.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,597

    Re: Countif not counting duplicate values correctly

    There's no need to concatenate at all if you use COUNTIFS.

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,260

    Re: Countif not counting duplicate values correctly

    Ali, True... but who knows if some of the strings alone are not >15 characters!! and there my be a reason for wanting to conatenate them that we know nothing about!!

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,597

    Re: Countif not counting duplicate values correctly

    Who knows?

  7. #7
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,669

    Re: Countif not counting duplicate values correctly

    yes, i did not mean for this to go into programming section...sorry about that.

    when you concatenate you can only concatenate up to 15 characters?


    also, i did not understand your soln....can you explain further.....
    i thought countifs was only for summing things

  8. #8
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,669

    Re: Countif not counting duplicate values correctly

    so i think you're right.........but i was not trying ot really have a "number" for the concatenated string.......so to make sure the concatenate was a string i added "a" to the beginning and
    then this gave me the correct counts.........thanks....

  9. #9
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,260

    Re: Countif not counting duplicate values correctly

    No you can concatenate >>15 characters. It's just that COUNTIF will try to convert the big string back into a number and will then only look at the first 15 characters. So these two:

    107888344610834201
    107888344610834202

    are seen by COUNTIFS as being

    107888344610834
    107888344610834

    which are the same. The advantage SUMPRODUCT has is that it will look at the entire string, be it 1 or 100 characters and llok for a match - returning TRUE or FALSE... whcich the -- converts into 1 or 0 and which SUMPRODUCT then adds up.


    You're welcome.


    It would be very nice if you were to just click the Add Reputation button at the foot of any of the posts of members who helped you reach a solution.

    Finally, if that takes care of your original question, please select "Thread Tools" from the menu link (just above the first post in the thread) and mark this thread as SOLVED.
    Last edited by Glenn Kennedy; 02-21-2022 at 01:14 PM.

+ 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. CountIF date/time not counting correctly
    By lvl133 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-02-2019, 08:01 PM
  2. [SOLVED] Countif statement not counting correctly for percentages
    By dcoates in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-10-2016, 02:04 PM
  3. [SOLVED] COUNTIF not counting correctly
    By helencj in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-24-2015, 07:42 AM
  4. Countif not counting date correctly
    By ciresuark in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-03-2015, 07:27 PM
  5. [SOLVED] SUMPRODUCT, COUNTIF formulas not correctly counting based on two sets of criteria
    By justinbelkin in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-11-2013, 10:12 AM
  6. Replies: 7
    Last Post: 12-16-2012, 08:24 PM
  7. Countif not counting correctly...
    By AaronK in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-18-2012, 12:43 PM

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