+ Reply to Thread
Results 1 to 15 of 15

how to select distinct values from list

  1. #1
    Registered User
    Join Date
    04-14-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    127

    how to select distinct values from list

    Hi all,

    Can someone please help me.

    I want a formula to select unique values from the list.
    I mean if there are values like -1, 5, #REF, 5, 1

    Answer should be 2.

    Regards,
    Vikas
    Last edited by kisanvikas2015; 06-08-2015 at 02:55 AM.

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

    Re: how to select distinct values from list

    Hi there. try this (assuming data are in a column, staring in A1).

    =SUM(IF(FREQUENCY(IF(A1:A5>0,A1:A5),IF(A1:A5>0,A1:A5))>0,1))

    This is an Array Formulas. They're a little different from ordinary formulas in that they MUST be confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER.

    You will know the array is active when you see curly braces { } appear around the outside of your formula. If you do not CTRL+SHIFT+ENTER you will get an error message or an incorrect answer. Press F2 on that cell and try again.

    Don't type the curly braces yourself - it won't work...
    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.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Registered User
    Join Date
    04-14-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    127

    Re: how to select distinct values from list

    Hi Glenn,

    Thanks for the response. I missed exclamation sign after #REF

    The formula should ignore any error like #NAME?, #VALUE!, #DIV/0!, #REF!

    Regards,
    Vikas

  4. #4
    Forum Contributor jayajaya_4's Avatar
    Join Date
    05-09-2015
    Location
    India
    MS-Off Ver
    2007
    Posts
    259

    Re: how to select distinct values from list

    use =iferror(SUM(IF(FREQUENCY(IF(A1:A5>0,A1:A5),IF(A1:A5>0,A1:A5))>0,1)),"")

  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 2403
    Posts
    44,053

    Re: how to select distinct values from list

    In your first post - why is the answer 2, not 3?

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

    Re: how to select distinct values from list

    Did you change the criteria back at Post 1?? I would swear that it originally said unique POSITIVE numbers... For the words as currently there, try this, also entered as an array (It'll give 3 as the answer).

    =SUM(IF(1-ISERROR($A$1:$A$5),IF($A$1:$A$5<>"",1))/COUNTIF($A$1:$A$5,$A$1:$A$5&""))

  7. #7
    Registered User
    Join Date
    04-14-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    127

    Re: how to select distinct values from list

    Quote Originally Posted by Glenn Kennedy View Post
    In your first post - why is the answer 2, not 3?
    @Glenn I want to ignore any kind of error.

    Regards,
    Vikas

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

    Re: how to select distinct values from list

    But why is the expected answer 2 and not 3... Minus 1, plus 1 and plus 5 = 3, not 2...

  9. #9
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: how to select distinct values from list

    Maybe this...

    Data Range
    A
    B
    C
    1
    -1
    3
    2
    5
    3
    #REF
    4
    5
    5
    1
    6
    ------
    ------
    ------


    This array formula** entered in C1:

    =SUM(IF(FREQUENCY(IF(ISNUMBER(A1:A5),A1:A5),A1:A5),1))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.
    Last edited by Tony Valko; 06-08-2015 at 08:20 AM.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  10. #10
    Registered User
    Join Date
    04-14-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    127

    Re: how to select distinct values from list

    Quote Originally Posted by Glenn Kennedy View Post
    But why is the expected answer 2 and not 3... Minus 1, plus 1 and plus 5 = 3, not 2...
    Hi Glenn,

    I want to count unique positive numbers only (ignoring any type of error)

    Regards,
    Vikas

  11. #11
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: how to select distinct values from list

    Quote Originally Posted by kisanvikas2015 View Post

    I want to count unique positive numbers only (ignoring any type of error)
    Try this array formula**

    =SUM(IF(FREQUENCY(IF(ISNUMBER(A1:A5),IF(A1:A5>0,A1:A5)),A1:A5),1))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

  12. #12
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: how to select distinct values from list

    Try this

    =SUMPRODUCT(ISNUMBER(A1:A5)*(A1:A5>0)/COUNTIF(A1:A5,A1:A5))
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

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

    Re: how to select distinct values from list

    OK. Why did you REMOVE the criterion of "positive number" from your edit of Post 1. We could have got to the answer FAR more quickly if you had left it in!! I would have suggested this much earlier on:

    =SUM(IF(1-ISERROR($A$1:$A$5),IF($A$1:$A$5>0,1))/COUNTIF($A$1:$A$5,$A$1:$A$5&""))

    array entered. You (finally) have several working formulae...

  14. #14
    Registered User
    Join Date
    04-14-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    127

    Re: how to select distinct values from list

    Quote Originally Posted by Glenn Kennedy View Post
    OK. Why did you REMOVE the criterion of "positive number" from your edit of Post 1. We could have got to the answer FAR more quickly if you had left it in!! I would have suggested this much earlier on:

    =SUM(IF(1-ISERROR($A$1:$A$5),IF($A$1:$A$5>0,1))/COUNTIF($A$1:$A$5,$A$1:$A$5&""))

    array entered. You (finally) have several working formulae...
    Hi Glenn,

    Thanks for answer.

    Sorry for the confusion.

    Thanks to all for helping me.

    Regards,
    Vikas

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

    Re: how to select distinct values from list

    Glad to have helped! If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. It'd also be appreciated if you were to click the add Reputation button at the foot of any of the posts of those who helped you reach a solution.

+ 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. howto select distinct values from list
    By chris in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 06-05-2015, 12:16 AM
  2. [SOLVED] Create validation list of distinct values
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-06-2014, 01:46 AM
  3. [SOLVED] Distinct List from Column of Values
    By dianaschar in forum Excel General
    Replies: 4
    Last Post: 03-26-2013, 11:39 AM
  4. Data Validation Returning only distinct values from a list
    By JI in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-28-2006, 06:45 PM
  5. Select Distinct Maximums
    By Zeepowlee in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-05-2006, 01:20 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