+ Reply to Thread
Results 1 to 29 of 29

Find Multiple Occurrence of ID within ranked list, return unique ID

  1. #1
    Registered User
    Join Date
    06-10-2010
    Location
    Berkshire, England
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    67

    Find Multiple Occurrence of ID within ranked list, return unique ID

    Hello,

    I am trying to resolve a complex relationship between Child ID's belonging to Parent ID's, according to a ranked list.
    An ID can exist in multiple forms as a child to different Parent ID's.

    Please see attached example of 20 records in which I need to create a unique set of ID's in which a child ID is eliminated if it exists within another (parent) ID.

    For example:
    ID 1020 exists as a child of ID 1019. However, ID 1019 is a child of ID 1003. However, ID 1003 is a child of 1002.
    Therefore, I now need to check where ID 1020 has a second relationship. It is a child of ID 1016. However, ID 1016 is a child of ID 1008. However, that is a child of ID 1006.
    Therefore, I now need to check ID 1020 has a third relationship. It is a child of ID 1005 which has no other relationship.

    So ID 1020 is not unique and is excluded. But ID 1005 is - which is retained.

    Another example:
    ID 1001 and ID 1002 have no other relationship so they are unique.
    ID 1003 is a child of ID 1002. Therefore, ID 1003 is immediately excluded. Any children of ID 1003 can now be checked for any other relationship.

    Another example:
    ID 1019 is a child of ID 1003. However, ID 1003 is already excluded so ID 1019 is unique.


    I have thousands of records in total where an ID is a child of many, higher ranked ID's. Can anyone please help with a process of investigating unique ID's please?
    Thanks SO much!

    Ben.Unique Rank Example.xlsx

  2. #2
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,427

    Re: Find Multiple Occurrence of ID within ranked list, return unique ID

    I do not quite understand what the intention is.
    I'm probably overlooking something.

    Looking at 1002, 1003 and 1019.
    1019 is a child of 1003 and 1003 is a child of 1002.

    I understand that 1003 should be eliminated and 1002 and 1019 remain. Is that correct?

    What exactly is the rule used to determine whether or not an ID should be eliminated?
    Perhaps a drawing with the relationships would explain this better?
    Can you explain this with other words (or a drawing)?

  3. #3
    Registered User
    Join Date
    06-10-2010
    Location
    Berkshire, England
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    67

    Re: Find Multiple Occurrence of ID within ranked list, return unique ID

    Thanks for the quick response.

    Correct, 1003 is eliminated as it is a child of 1002. As 1003 is excluded from the analysis, ID 1019 also remains as it is only a child of 1003.
    In each instance, the highest ranked ID is kept, unless it is a child of a higher ranked ID. Any other ID is also eliminated, unless it's higher ranked Parent ID has already been eliminated.

    I should also add. In my actual source data, the 8000+ records I have is contained in just three columns:
    ID, Rank, Child ID

  4. #4
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,427

    Re: Find Multiple Occurrence of ID within ranked list, return unique ID

    ID 1019 also remains as it is only a child of 1003.
    I don't understand this, because also 1003 is only a child of 1002, but 1003 does not remain.

    In each instance, the highest ranked ID is kept, unless it is a child of a higher ranked ID. Any other ID is also eliminated, unless it's higher ranked Parent ID has already been eliminated.
    I find this sentence even more complicated. English is not my native language. Surely parents always have a lower rank number than his children? Can you explain the whole thing with other words? How can you check if you have kept or removed the good person? And is one the highest rank or the lowest rank???

  5. #5
    Registered User
    Join Date
    06-10-2010
    Location
    Berkshire, England
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    67

    Re: Find Multiple Occurrence of ID within ranked list, return unique ID

    ID 1003 is eliminated because it is a 'child' of ID 1002 (which has a higher ranking). Therefore, ID 1003 in effect no longer exists as a Parent ID of 1019.
    ID 1002 is a confirmed record; now ID 1019 can be a confirmed record as it is not a child of any other ID.

  6. #6
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,427

    Re: Find Multiple Occurrence of ID within ranked list, return unique ID

    Please try in G2 and copy down (the table should be sorted on rank):
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  7. #7
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,427

    Re: Find Multiple Occurrence of ID within ranked list, return unique ID

    The above formula can be shortened to (same result):

    Please try in G2 and copy down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    06-10-2010
    Location
    Berkshire, England
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    67

    Re: Find Multiple Occurrence of ID within ranked list, return unique ID

    Thanks for taking a look at this. This isn't the solution, however.

    For example, ID 1020. I need to be able to check if this ID belongs to a higher ranked parent ID. In this case, it has three parent ID's and ultimately the result should show that ID 1005 is the only Parent ID which doesn't also have a higher ranked Parent ID with a higher ranking.

  9. #9
    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,846

    Re: Find Multiple Occurrence of ID within ranked list, return unique ID

    What is the OUTPUT that you are aiming for?

    I don't understand the way that the relationships work.
    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.

  10. #10
    Registered User
    Join Date
    06-10-2010
    Location
    Berkshire, England
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    67

    Re: Find Multiple Occurrence of ID within ranked list, return unique ID

    A unique list of (parent) ID's, where that particular ID is not a child of a higher ranked ID. The updated attachment is probably a better example to use.

    I have a list of 5,000+ records in total which are set out in the same fashion as this example.

    If an ID exists as a child of a higher ranked ID then this is eliminated and removed from the equation.

    Take ID 1010 as an example, ranked 10th. This already exists as a child of ID 1004 (ranked 4th). However, ID 1004 is a child of ID 1003 (ranked 3rd).
    ID 1004 is therefore removed.
    So now I need to check if ID 1010 is found elsewhere and it is, as a child of ID 1005 (ranked 5th). However, ID 1005 is a child of ID 1001 (ranked 1st).
    ID 1005 is therefore removed.
    So let's check the existence of ID 1010 once again. It is also a child of ID 1007 (ranked 7th). However, ID 1007 is a child of ID 1006 (ranked 6th).
    However, ID 1006 is a child of ID 1003 (ranked 3rd).
    ID 1006 is therefore removed.
    ID 1007 is also removed as it is also a child of ID 1003.
    ID 1010 is then checked once again for its appearance in the second column and it is found as a child of ID 1009 (ranked 9th).
    ID 1009, however, is a child of ID 1008 (ranked 8th). ID 1008 is also a child of ID 1006 but this ID has already been removed from the checking process.
    ID 1008 is also a child of ID 1002. However, ID 1002 will have been removed from the check as it is lower ranked than ID 1001 which it is a child of.

    Therefore, ID 1010 is retained as a unique ID because all of its occurrences as a child of a higher ranked ID are instances where that higher ranked ID has been effectively removed from the process.

    This exercise has to be repeated for each and every ID.Unique Rank Example v2.xlsx

  11. #11
    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,846

    Re: Find Multiple Occurrence of ID within ranked list, return unique ID

    Which is the OUTPUT column? Column C?
    Last edited by AliGW; 07-06-2023 at 09:05 AM. Reason: Typo fixed.

  12. #12
    Registered User
    Join Date
    06-10-2010
    Location
    Berkshire, England
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    67

    Re: Find Multiple Occurrence of ID within ranked list, return unique ID

    There is no output yet. The example file is how the data currently sits. I need to provide the output as described in my previous post.

  13. #13
    Registered User
    Join Date
    06-10-2010
    Location
    Berkshire, England
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    67

    Re: Find Multiple Occurrence of ID within ranked list, return unique ID

    The result of the example would be this as per this: Unique Rank Example v3.xlsx

  14. #14
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,427

    Re: Find Multiple Occurrence of ID within ranked list, return unique ID

    This solution uses 2 help tables

    Please try in I2:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    in L2 and copy down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    and try for the final result in P2:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  15. #15
    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,846

    Re: Find Multiple Occurrence of ID within ranked list, return unique ID

    I've been mulling over this for a few days.

    Can someone explain in detail why 1007 and 1009 are not included? At what point exactly in the chain do they fail the test? I am trying to understand the logic.

  16. #16
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,427

    Re: Find Multiple Occurrence of ID within ranked list, return unique ID

    @Ali,

    It also took me a while to understand.
    The rule I have applied is that someone may only be included if a parent has not previously been included.
    The order in which this is assessed is by rank number from low to high.

    In other words, everyone in the list doesn't have a parent with a lower ranking number who is also in the list.

    So 1007 is not included, because parent 1003 of 1007 is included.
    And 1009 is not included, because parent 1008 of 1009 is included.

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

    Re: Find Multiple Occurrence of ID within ranked list, return unique ID

    OK - I'm not sure that fully answers my question, but I'll have another look when I get back from shopping. I understand how your solution works, just not how it handles the logic - yet! Thank you.

  18. #18
    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,846

    Re: Find Multiple Occurrence of ID within ranked list, return unique ID

    Got it - thanks. I can't help thinking that there must be a way to do this in one fell swoop, but I can't see how to handle the recursive search. Thanks again.

    I hope the OP will appreciate your efforts on their behalf.

  19. #19
    Registered User
    Join Date
    06-10-2010
    Location
    Berkshire, England
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    67

    Re: Find Multiple Occurrence of ID within ranked list, return unique ID

    ....ID 1007 isn't included because it is a 'child' of 1006 and 1003. The higher rank ID is ALWAYS retained, unless that ID is also a child of higher-ranked ID.
    1006 is excluded because that ID itself is a child of 1003. 1003 is not a child of either 1002 or 1001 so 1003 is retained and therefore 1006 and 1007 are excluded.

    1009 is excluded because it is a child of 1008 and 1005, 1004 and 1002. Only 1008 is retained from that list, however, as the three other ID's are children of higher ranked - and retained - ID's.

  20. #20
    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,846

    Re: Find Multiple Occurrence of ID within ranked list, return unique ID

    Please feed back on Hans' solution (post #14).

  21. #21
    Registered User
    Join Date
    06-10-2010
    Location
    Berkshire, England
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    67

    Re: Find Multiple Occurrence of ID within ranked list, return unique ID

    Thank you for this suggestion. I have copied the formulas into my file but unfortunately the final result comes up with a SPILL error.

  22. #22
    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,846

    Re: Find Multiple Occurrence of ID within ranked list, return unique ID

    You will need to clear all data around and about to make room for the spillage. The formulae work as you can see from the attachment that Hans provided.

    I1 to Q12 need to be EMPTY.

  23. #23
    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,846

    Re: Find Multiple Occurrence of ID within ranked list, return unique ID

    Use the attached version of Hans' file.

    I have moved the ultimate results table. The two helper tables need room - the first will extend downwards as you add data to the source table, and the second one will need dragging down to match and will expand to the right depending on the number of children.

    I presume you have adapted the ranges in the formulae to suit your larger (5000+ records) dataset?
    Attached Files Attached Files

  24. #24
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,427

    Re: Find Multiple Occurrence of ID within ranked list, return unique ID

    ....ID 1007 isn't included because it is a 'child' of 1006 and 1003. The higher rank ID is ALWAYS retained, unless that ID is also a child of higher-ranked ID.
    1006 is excluded because that ID itself is a child of 1003. 1003 is not a child of either 1002 or 1001 so 1003 is retained and therefore 1006 and 1007 are excluded.
    This amounts to exactly what I am saying. 1007 is excluded, because the parent of 1007 being 1003 is not excluded.
    For me, my own wording of post #14 is easier to understand (or less easy to read in different ways).
    The concept of higher ranked is so confusing for a non-English speaking person, because the rest shows that the lower the ranking number, the higher the ranking.

    The result of my reasoning turns out to be exactly correct.

  25. #25
    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,846

    Re: Find Multiple Occurrence of ID within ranked list, return unique ID

    I thought your explanation was clearer, too, Hans, and I'm a native English speaker!

  26. #26
    Registered User
    Join Date
    06-10-2010
    Location
    Berkshire, England
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    67

    Re: Find Multiple Occurrence of ID within ranked list, return unique ID

    Thank you Hans - this works. You are a magician!!
    Thank you so much for your assistance and you too Ali.

    (By the way, I didn't really understand your explanation, whereas I could follow my own - but hey, ho - we got there in the end!!!!

  27. #27
    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,846

    Re: Find Multiple Occurrence of ID within ranked list, return unique ID

    Glad to have helped.

    If that takes care of your original question, please choose Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank anyone who offered you help towards a solution for your issue by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.

  28. #28
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,427

    Re: Find Multiple Occurrence of ID within ranked list, return unique ID

    You are Welcome.
    Thanks for your feedback, Glad to have helped.

    Please consider adding reputation to any helpers you think they deserve.
    In that case please click * Add Reputation left below their answers.

  29. #29
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,427

    Re: Find Multiple Occurrence of ID within ranked list, return unique ID

    Thanks for the reputation .

+ 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: 3
    Last Post: 09-24-2022, 08:11 AM
  2. [SOLVED] Return most recent occurrence in list based on multiple array criteria
    By Marbleking in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 09-05-2020, 03:37 PM
  3. [SOLVED] Return highest ranked player up to a maximum position in the list
    By mozartk626 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-19-2020, 08:45 AM
  4. Replies: 11
    Last Post: 01-30-2020, 04:34 AM
  5. create ranked list of unique codes with subtotals
    By ozbrian in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-16-2019, 04:53 PM
  6. [SOLVED] Find unique entries and create ranked list with formulas only
    By opheim in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-08-2013, 04:09 AM
  7. Extract a sorted and ranked unique list of items
    By bruno_ in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-11-2013, 09:52 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