+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 14 of 17
  1. #1
    Registered User
    Join Date
    04-07-2009
    Location
    Los Angeles, United States
    MS-Off Ver
    Office 2008-Mac
    Posts
    49

    Count unique values

    Card Number
    XXXX5512
    XXXX5512
    XXXX4211
    XXXX4510
    XXXX6134
    XXXX9035
    XXXX6002
    XXXX8653
    XXXX7826
    XXXX8819
    XXXX8315
    XXXX0274

    I'm looking for a formula to generate the number of unique card numbers are in the column...I'm using this daily, simply pasting the new data in so if I want to keep it as automated as possible. Thanks for your help!

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Cochrane,Alberta
    MS-Off Ver
    XL 2003,2007
    Posts
    6,259

    Re: Count ONLY unique values in column

    This will count the unique items in a range
    In your case the answer is 11

    =SUMPRODUCT((A2:A13<>"")/COUNTIF(A2:A13,A2:A13&""))
    Dave


  3. #3
    Registered User
    Join Date
    04-07-2009
    Location
    Los Angeles, United States
    MS-Off Ver
    Office 2008-Mac
    Posts
    49

    Re: Count ONLY unique values in column

    Dave thanks for the quick reply.

    I want to be able to automate this so I want it to do all values in the row starting at Q24 no matter how many there are in the column. Some days, like yesterday there were 333, today there's 450. Is there a way to only count cells with a value in it...I tried to just do a safe range to 1000 and it's giving me #div/0! error.

    Thanks a ton for your help!

  4. #4
    Forum Guru darkyam's Avatar
    Join Date
    03-05-2008
    Location
    Colorado, US
    MS-Off Ver
    2007
    Posts
    2,140

    Re: Count ONLY unique values in column

    You can change references to A2:A13 to A2:Index(A:A,COUNT(A:A)+1)

  5. #5
    Forum Moderator Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2007
    Posts
    5,212

    Re: Count ONLY unique values in column

    Not sure why you're getting a DIV/0 error, unless you didn't specify a range with data in the denominator of Dave's function (the COUNTIF part).

    If I put data into Q24:Q60, and use the following formula it still works, even though 900+ rows are blank:

    =SUMPRODUCT((Q24:Q1000<>"")/COUNTIF(Q24:Q1000,Q24:Q1000&""))

  6. #6
    Forum Contributor
    Join Date
    07-24-2009
    Location
    Northborough, MA USA
    MS-Off Ver
    Excel 2010
    Posts
    197

    Re: Count ONLY unique values in column

    Here is another formula to try:

    Code:
    =SUM(IF(FREQUENCY(IF(LEN(A2:A1000)>0,MATCH(A2:A1000,A2:A1000,0),""),IF(LEN(A2:A1000)>0,MATCH(A2:A1000,A2:A1000,0),""))>0,1))
    This is an ARRAY formula so press Ctrl+Shift+Enter

  7. #7
    Forum Moderator teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    2003 & 2010
    Posts
    10,039

    Re: Count ONLY unique values in column

    Dave, Paul, why the coercion of the countif range into text? It seems to work just as well without it on either all text, all numeric or mixed values.
    teylyn
    Microsoft MVP - Excel
    At Excelforum, you can say "Thank you!" by clicking the icon below the post.

    Avoid pie charts with more than two data points. Why? See here (pdf, 559 kb). The only acceptable pie chart is here.

  8. #8
    Registered User
    Join Date
    04-07-2009
    Location
    Los Angeles, United States
    MS-Off Ver
    Office 2008-Mac
    Posts
    49

    Re: Count ONLY unique values in column

    Guys that worked perfectly....thanks so much!

  9. #9
    Registered User
    Join Date
    04-07-2009
    Location
    Los Angeles, United States
    MS-Off Ver
    Office 2008-Mac
    Posts
    49

    Re: Count ONLY unique values in column

    How about this one, this one's challenging....is there a way to find how many unique people there are...ie match first and last name in (column y, z in this example) and see how many unique people there are.

    I have faith you guys can somehow figure this one out, thanks in advanced!

  10. #10
    Forum Guru darkyam's Avatar
    Join Date
    03-05-2008
    Location
    Colorado, US
    MS-Off Ver
    2007
    Posts
    2,140

    Re: Count ONLY unique values in column

    A helper column with =Y1&Z1, then apply the same formula.

  11. #11
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,379

    Re: Count ONLY unique values in column

    Quote Originally Posted by teylyn View Post
    Dave, Paul, why the coercion of the countif range into text? It seems to work just as well without it on either all text, all numeric or mixed values.
    Did you try it with blanks...

  12. #12
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,379

    Re: Count ONLY unique values in column

    Quote Originally Posted by rkrieg View Post
    How about this one, this one's challenging....is there a way to find how many unique people there are...ie match first and last name in (column y, z in this example) and see how many unique people there are.
    Given your use of XL2008 you can use COUNTIFS rather than COUNTIF in the SUMPRODUCT

    Code:
    =SUMPRODUCT(--(Y24:Y1000&Z24:Z1000<>""),1/COUNTIFS(Y24:Y1000,Y24:Y1000&"",Z24:Z1000,Z24:Z1000&""))
    Pre XL2007 you would be best served using helpers as outlined else you would need to conduct a MATCH test to use the SUMPRODUCT approach else FREQUENCY Array.

  13. #13
    Registered User
    Join Date
    04-07-2009
    Location
    Los Angeles, United States
    MS-Off Ver
    Office 2008-Mac
    Posts
    49

    Re: Count unique values

    I actually tried that, it gave me the same #div/0! error. Little more mechanical, the =Y1&Z1, worked fine though.

    Is there a way to return a list of all the unique values in a column?

  14. #14
    Forum Guru darkyam's Avatar
    Join Date
    03-05-2008
    Location
    Colorado, US
    MS-Off Ver
    2007
    Posts
    2,140

    Re: Count unique values

    Advanced filter can give you that.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0