+ Reply to Thread
Results 1 to 4 of 4

Finding unique distinct values

  1. #1
    Registered User
    Join Date
    10-29-2013
    Location
    Maryland
    MS-Off Ver
    Microsoft? Excel? for Microsoft 365 MSO (Version 2305 Build 16.0.16501.20074) 64-bit
    Posts
    54

    Finding unique distinct values

    Hi all,

    I have a list of names (some duplicate) in a column that I want to extract only unique names in a different column.

    I found this formula (which works):

    =INDEX($A$2:$A$5,MATCH(0,INDEX(COUNTIF($B$1:B1,$A$2:$A$5),0,0),0))

    Is there a website that I can paste this formula and will explain it. Or can anyone here explain?

    Thanks in advance.

    Mark

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Finding unique distinct values

    Okay, As far as I know, there is no Excel Translator Web Engine. That would be pretty cool.

    Do you understand routine INDEX/MATCH Formulas?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Finding unique distinct values

    Let's start with
    Since we are looking at a single column, the second 0 (in red) is not necessary
    =INDEX($A$2:$A$5,MATCH(0,INDEX(COUNTIF($B$1:B1,$A$2:$A$5),0,0),0))
    so it should only be
    =INDEX($A$2:$A$5,MATCH(0,INDEX(COUNTIF($B$1:B1,$A$2:$A$5),0),0))

    Next lets look at
    COUNTIF($B$1:B1, $A$2:$A$5)

    Normally this would just return 0 because the second argument should be a single cell and it returns a single value. However, because it is entered as the Array argument for INDEX (INDEX(COUNTIF($B$1:B1, $A$2,$A$5),0), Excel expands it to an array and returns a value for every criteria in the second argument (A2:A5) so this gives us an array of {0;0;0;0} (The contents of B1 don't match A2:A5).

    So now, we have
    =INDEX($A$2:$A$5,MATCH(0,INDEX({0;0;0;0},0),0))
    This 0 (in red) tells Excel to take every row in the array. Normally there would be a number (1,2,3 or 4) and it would return the value in that row.
    So we are now at
    =INDEX($A$2:$A$5,MATCH(0,{0;0;0;0}))
    So Match (0...) returns a 1 because the first term of the array is 0

    Now we drag that formula down to B3 (Important that the first formula was in B2)
    Now the Formula reads
    =INDEX($A$2:$A$5,MATCH(0,INDEX(COUNTIF($B$1:B2,$A$2:$A$5),0,0),0))
    and when it counts B1:B2 against A2:A5, it counts 1 value for A2 so we get (if there are no duplicates)
    {1,0,0,0}
    Lets say the value in A3 is the same as A2, it would return
    {1,1,0,0}
    Now when the Match searches for 0, it goes to 3 and returns A4

    You probably want to wrap a IFERROR around your formula so it doesn't return errors

    =IFERROR(INDEX($A$2:$A$5,MATCH(0,INDEX(COUNTIF($B$1:B1,$A$2:$A$5),0),0)),"")

  4. #4
    Registered User
    Join Date
    10-29-2013
    Location
    Maryland
    MS-Off Ver
    Microsoft? Excel? for Microsoft 365 MSO (Version 2305 Build 16.0.16501.20074) 64-bit
    Posts
    54

    Re: Finding unique distinct values

    Thanks I will evaluate your response. Probably going to take me a while.

+ 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. Replies: 0
    Last Post: 07-21-2015, 04:44 PM
  2. [SOLVED] Excel - Count distinct occurences and copy unique values
    By random0munky in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-26-2015, 10:41 PM
  3. [SOLVED] Finding distinct values across multiple columns - FREQUENCY array?
    By brokenbiscuits in forum Excel General
    Replies: 4
    Last Post: 01-12-2015, 09:06 AM
  4. [SOLVED] Copy Unique Distinct Values
    By snapfade in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-17-2013, 10:33 AM
  5. Finding distinct values within a single string
    By balki42 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-25-2013, 06:39 AM
  6. Replies: 2
    Last Post: 01-21-2013, 12:07 AM
  7. Count of distinct (unique) values by day
    By velorian in forum Excel General
    Replies: 7
    Last Post: 12-06-2011, 05:03 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