+ Reply to Thread
Results 1 to 20 of 20

Find rows/groups with unique values and return

  1. #1
    Registered User
    Join Date
    06-21-2014
    Location
    India
    MS-Off Ver
    MS Excel 2016
    Posts
    34

    Lightbulb Find rows/groups with unique values and return

    I am having 127 columns and 405 rows. A row consist of a group and column has species name as given below.

    Table 1.
    Groups species
    Group[ 0 ] Olea_europaea Olea_europaea
    Group[ 1 ] Codium_arabicum Codium_arabicum
    Group[ 2 ] Codium_duthieae Codium_duthieae Codium_arabicum*
    Group[ 3 ] Rhazya_stricta
    * odd species in this group

    In result section, I need to have comments as below by matching the species list column from the table 2 to table 1:

    If Same species are grouped together and not found in any other group then : TRUE
    If Same species are grouped together but also found in other group then : AMBIGUOUS
    If Multiple species are grouped together then : INCORRECT
    If only one individual of representative species, this species in not in any other group then : SINGLETON

    Table 2.
    Species list Comment (Result)
    Codium_arabicum AMBIGIOUS
    Codium_duthieae INCORRECT
    Olea_europaea TRUE
    Rhazya_stricta SINGLETON

    Kindly, suggest formula to comment as above.
    Last edited by rajamdade; 03-09-2019 at 02:05 AM.

  2. #2
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Find rows/groups with unique values and return

    one option attached... leverages some basic helpers on results tab to keep calcs relatively lightweight.

    you may prefer to use a UDF / Sub Routine {VBA} to do this as would be much more efficient.


    to avoid getting into trouble with the mods - calcs involved below

    1. identify unique count of species - used to limit no. of calcs performed {given relatively expensive}

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    2. identify position in matrix of each unique item, in A-Z order

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    3. identify total count of species in data set
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    with above in place the actual results are then, simply:

    Species:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    the VB engine is preventing me from posting the final formula (for comment).

    NOTE:

    one question -- is the * in your sample set a literal * or did you add to highlight difference? if literal this will impact your unique count / countif type calcs, and would need to be addressed.
    Attached Files Attached Files
    Last edited by XLent; 03-09-2019 at 06:12 AM.

  3. #3
    Registered User
    Join Date
    01-09-2014
    Location
    Leeds, England
    MS-Off Ver
    Excel 365
    Posts
    72

    Re: Find rows/groups with unique values and return

    My solution is attached.

    Explanation:

    To identify SINGLETONS, simply use a COUNTIF. If there is only 1 instance of a species, it is a SINGLETON.

    To identify INCORRECT, I used a helper column to count the number of unique values in each group. If there are multiple unique species, then all species in that group must be INCORRECT. I then used the TEXTJOIN function to join all the names together into an "Incorrect" column. I then searched for the species name in the column, and if it appears, return INCORRECT.

    To identify TRUE, and as we have already identified singletons, we just need to see how many group a species is in. Again using a helper column to join all names together, search for a name and if there is only 1 result, return TRUE.

    All others must be AMBIGIOUS, provided there is at least 1 instance, otherwise return a blank cell.


    One point to note, I catagorised both Codium_arabicum and Codium_duthieae as INCORRECT, as both appear in Group 2, and if multiple species are grouped together they are INCORRECT. You had Codium_arabicum listed as AMBIGIOUS, which I think is wrong by your logic.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    06-21-2014
    Location
    India
    MS-Off Ver
    MS Excel 2016
    Posts
    34

    Re: Find rows/groups with unique values and return

    Thank you very much! XLent & SimonLock it worked...

    * was added to highlight difference only...

    I am having one more problem in the species names: Every species has unique accession ids like in"Olea_europaea" for Table No. 1:
    LT222085.1|Olea_europaea LT222086.1|Olea_europaea

    How can I ignore the accession ids for getting results as in Table No. 2.
    Last edited by rajamdade; 03-09-2019 at 07:48 AM.

  5. #5
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Find rows/groups with unique values and return

    If I've understood, refer attached... this will effect strip out the prefix when establishing uniqueness etc

    however, the drawback is loss of ordering A-Z as this becomes significantly more complex.

    note: addition of pipe character on Data sheet, cell C1 {to aid unique calc in cell A1 on Results tab}


    edit: if you don't need / wish to dynamically create the results table (based on data in matrix) then don't use my proposed approaches.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    06-21-2014
    Location
    India
    MS-Off Ver
    MS Excel 2016
    Posts
    34

    Re: Find rows/groups with unique values and return

    Thank you! XLent
    I really appreciate your efforts dear XLent "EXCELLENT"

  7. #7
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,990

    Re: Find rows/groups with unique values and return

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.
    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.

  8. #8
    Registered User
    Join Date
    06-21-2014
    Location
    India
    MS-Off Ver
    MS Excel 2016
    Posts
    34

    Re: Find rows/groups with unique values and return

    Dear XLent,

    I tried to analyze using my data, but species from one group went missing:

    Group[ 404 ] LT222085.1|Quercus_coccifera LT222089.1|Quercus_coccifera


    hereby forwarding the original data.

    Thanks in advance!
    Attached Files Attached Files

  9. #9
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Find rows/groups with unique values and return

    add a ROUND to A1:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    edit: added file w/above adjustment and tweak on "key" calc.
    Attached Files Attached Files
    Last edited by XLent; 03-10-2019 at 04:09 AM.

  10. #10
    Registered User
    Join Date
    06-21-2014
    Location
    India
    MS-Off Ver
    MS Excel 2016
    Posts
    34

    Re: Find rows/groups with unique values and return

    Yes this solved the problem.
    Many thanks XLent!

  11. #11
    Registered User
    Join Date
    06-21-2014
    Location
    India
    MS-Off Ver
    MS Excel 2016
    Posts
    34

    Arrow Re: Find rows/groups with unique values and return

    Dear @XLent,

    Hope you are doing well, I have been using your formulated .xlsb file without any errors or issues to date. However, with the present dataset, I am getting errors as '#NUM' in the 'results sheet' from the line no. 334. I would appreciate it if you could help us to resolve the issue in the file attached hereby.

    Kind regards,
    Rahul
    Attached Files Attached Files

  12. #12
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,990

    Re: Find rows/groups with unique values and return

    You will want to remove the SOLVED tag from the thread if you wish for further help.

  13. #13
    Registered User
    Join Date
    06-21-2014
    Location
    India
    MS-Off Ver
    MS Excel 2016
    Posts
    34

    Re: Find rows/groups with unique values and return

    Hi,

    I have already removed the SOLVED tag from the thread. Thank you!

  14. #14
    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,067

    Re: Find rows/groups with unique values and return

    Are you still using Excel 2016, or have you upgraded to something more recent?? Please confirm and/or amend your profile.

    Specifically, I need to know a) if you have Office 365 and b) if you are using a PC (i.e. not a Mac). If yes & yes.... this is simple to do.
    Last edited by Glenn Kennedy; 07-13-2021 at 10:18 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.

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

  15. #15
    Registered User
    Join Date
    06-21-2014
    Location
    India
    MS-Off Ver
    MS Excel 2016
    Posts
    34

    Re: Find rows/groups with unique values and return

    @Glenn Kennedy thank you for your quick response, I am still using MS excel 16. Kindly suggest the solution accordingly.

  16. #16
    Valued Forum Contributor
    Join Date
    06-23-2021
    Location
    Romania
    MS-Off Ver
    2021, 365 v 2208
    Posts
    722

    Re: Find rows/groups with unique values and return

    I used PQ to unpivot your table and tried to do the required calculations. I hope it came out right
    HTML Code: 
    Attached Files Attached Files
    Diana Tanase


    If the solutions offered helped you to solve your problem, then mark the thread as SOLVED (thread tools in the top menu) and you can click on * to add reputation to those who helped you, as a way to say thank you !

  17. #17
    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,067

    Re: Find rows/groups with unique values and return

    I will not pretend to understand the formulae in use in column A... I have changed the formulae in the bits shaded red... At least it goes all the way to 382 now...
    Attached Files Attached Files

  18. #18
    Registered User
    Join Date
    06-21-2014
    Location
    India
    MS-Off Ver
    MS Excel 2016
    Posts
    34

    Re: Find rows/groups with unique values and return

    @Glenn,
    All these two days I tried executing with new data in the given .xlsb file. The "interim" sheet seems working fine, but the "Results" sheet doesn't seem to display results. Is there anything I am missing?
    Attached Files Attached Files

  19. #19
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Find rows/groups with unique values and return

    I've not been on the board much of late so didn't see this until today.
    I have been using your formulated .xlsb file without any errors or issues to date. However, with the present dataset, I am getting errors as '#NUM' in the 'results sheet' from the line no. 334.
    as the matrix now exceeds 100 columns the previous calculation (Col A) will not generate the holistic list of unique co-ordinates; to address, change references to 100 in both A3 & C3 to 1000, and copy down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by XLent; 07-21-2021 at 07:04 AM. Reason: undesired @

  20. #20
    Registered User
    Join Date
    06-21-2014
    Location
    India
    MS-Off Ver
    MS Excel 2016
    Posts
    34

    Re: Find rows/groups with unique values and return

    Thank you very much @XLent, the issue has been resolved.

+ 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. Count unique values within certain groups
    By lime10131 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-24-2015, 08:39 AM
  2. Finding unique groups of values in columns
    By colmoshea in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 12-17-2013, 10:44 AM
  3. Replies: 2
    Last Post: 12-04-2013, 09:45 PM
  4. Need forumla to sum number of unique values in groups of different sizes
    By ea2146 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-30-2013, 02:33 PM
  5. Excel 2007 - Formula or VBA to find unique names and return values?
    By kjwaller in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-02-2013, 09:09 PM
  6. [SOLVED] Find unique duplicate values in rows
    By Bay in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 06-03-2011, 10:52 AM
  7. Find unique value in column and return multiple values
    By DWolf75 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-16-2011, 08:32 PM

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.6.0 RC 1