+ Reply to Thread
Results 1 to 9 of 9

Counting the common unique values between two comma-separated lists

  1. #1
    Registered User
    Join Date
    08-11-2017
    Location
    Budapest
    MS-Off Ver
    2016
    Posts
    68

    Counting the common unique values between two comma-separated lists

    I need help with a formula to count the unique values in two cells with comma separated values.

    My data is like this in column A:

    12,12,13,14,16,17,20
    11,13,17,18,18,20

    The expected result for these in column B1: 3


    Note: The values in each comma-separated list all are positive but may contain duplicates.

    I am open to a vba solution too. Thank you.
    Attached Files Attached Files
    Last edited by max333; 07-20-2020 at 11:52 AM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,929

    Re: Counting the common unique values between two comma-separated lists

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    (Note: this requirement is not optional. No help to be offered until the link is provided.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    08-11-2017
    Location
    Budapest
    MS-Off Ver
    2016
    Posts
    68

    Re: Counting the common unique values between two comma-separated lists

    Thanks. Here is the other link I cross posted. https://www.mrexcel.com/board/thread...lists.1140564/

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,929

    Re: Counting the common unique values between two comma-separated lists

    Are you still using XL2007 or a later version. If later, please update your profile as a solution may not be appropriate to your version. Some more advanced features are available in later versions.

  5. #5
    Registered User
    Join Date
    08-11-2017
    Location
    Budapest
    MS-Off Ver
    2016
    Posts
    68

    Re: Counting the common unique values between two comma-separated lists

    Thanks. I updated my profile. I use 2016 version.

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,929

    Re: Counting the common unique values between two comma-separated lists

    I am not understanding your expected results. Could you explain your logic and criteria that you used to obtain the expected results. If I count manually the unique values in your post #1, I get 7 unique values between the two rows. How do you arrive at 3?

  7. #7
    Registered User
    Join Date
    08-11-2017
    Location
    Budapest
    MS-Off Ver
    2016
    Posts
    68

    Re: Counting the common unique values between two comma-separated lists

    the first two rows:

    12,12,13,14,16,17,20
    11,13,17,18,18,20

    the result is 3 because 13,17,20 are in both rows.

    I only need the common / shared unique values in both cells.

    for example:

    11,14,16,17,18,19,19,20
    12,12,13,16,17,19,20

    here result is : 4 ( 16,17,19,20) even though there are two 19s in the first list, it is counted once.
    Last edited by max333; 07-20-2020 at 01:24 PM.

  8. #8
    Registered User
    Join Date
    08-11-2017
    Location
    Budapest
    MS-Off Ver
    2016
    Posts
    68

    Re: Counting the common unique values between two comma-separated lists

    so if there was a situation like this:

    15,15,19
    15,15,20

    The result would be 1. because one unique number is present in both lists. (15).

    I hope this makes it clearer. if not you can ask me.

  9. #9
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: Counting the common unique values between two comma-separated lists

    Please try at C2
    for Fixed 2 digits number

    =COUNT(MATCH(IF(FREQUENCY(--MID(A2,ROW(A$1:INDEX(A:A,LEN(A2)-LEN(SUBSTITUTE(A2,",",))+1))*3-2,2),ROW(A$1:A$99)),ROW(A$1:A$99)),--MID(A3,ROW(A$1:A$20)*3-2,2),))

    or 1-3 digits

    =COUNT(MATCH(IF(FREQUENCY(FILTERXML("<b><a>"&SUBSTITUTE(A2,",","</a><a>")&"</a></b>","//a"),ROW($A$1:$A$999)),ROW($A$1:$A$999)),FILTERXML("<b><a>"&SUBSTITUTE(A3,",","</a><a>")&"</a></b>","//a"),))


    Or UDF =CommonU(A2)

    Please Login or Register  to view this content.
    or Power Query

    Please Login or Register  to view this content.
    Attached Files Attached Files

+ 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] Return unique values from list as a comma separated string
    By dridlebert in forum Excel General
    Replies: 2
    Last Post: 06-04-2020, 11:02 AM
  2. Advanced Character Length Counting (Comma separated values)
    By jderosa3 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 05-09-2020, 03:45 PM
  3. Replies: 3
    Last Post: 12-26-2019, 09:59 AM
  4. Replies: 5
    Last Post: 05-20-2016, 03:22 AM
  5. Counting texts separated by a comma
    By Elainefish in forum Excel General
    Replies: 13
    Last Post: 01-12-2016, 08:33 PM
  6. Comma Separated Cell Values to Column of Unique Cell Values
    By Nuggetross in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-02-2014, 07:24 PM
  7. [SOLVED] Macro to give the count of unique values after comparing the comma separated values
    By Manish_Gupta in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-03-2014, 12:41 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