+ Reply to Thread
Results 1 to 10 of 10

Parent Child relationship issue: Get parent ID for child

  1. #1
    Registered User
    Join Date
    08-28-2018
    Location
    Germany
    MS-Off Ver
    Office 365
    Posts
    3

    Parent Child relationship issue: Get parent ID for child

    Hi,

    it is difficult to describe my issue in the Titel so here is my problem.

    I have an excel List with lets say 5 rows + Header and 3 columns


    ID Type Title
    1 Parent MyParentTitle
    2 Child MyCildTitle1
    3 Child MyChildTitle2
    4 Parent MyParentTitle2
    5 Child MyChildTitle3

    What I need is to get the Parent ID for each Child. So the table should look like that:

    ID Type Title ParentID
    1 Parent MyParentTitle
    2 Child MyCildTitle1 1
    3 Child MyChildTitle2 1
    4 Parent MyParentTitle2
    5 Child MyChildTitle3 4


    A Parent might have 0-n childs. Childs are always listed under the parent.

    Any ideas?

    Thanks in advance

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2502 (Windows 11 Home 24H2 64-bit)
    Posts
    89,559

    Re: Parent Child relationship issue: Get parent ID for child

    Will children always be listed on the rows immediately after their parent?
    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. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    08-28-2018
    Location
    Germany
    MS-Off Ver
    Office 365
    Posts
    3
    Quote Originally Posted by AliGW View Post
    Will children always be listed on the rows immediately after their parent?
    Yes. Childs are always listed after their parent

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2502 (Windows 11 Home 24H2 64-bit)
    Posts
    89,559

    Re: Parent Child relationship issue: Get parent ID for child

    In D2 copied down:

    =IFERROR(IF(B2="Child",LOOKUP(2,1/(B$2:B2="Parent"),A$2:A2),""),"")

    Ins Deutsche übersetzt:

    =WENNFEHLER(WENN(B2="Child";VERWEIS(2;1/(B$2:B2="Parent");A$2:A2);"");"")

  5. #5
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Parent Child relationship issue: Get parent ID for child

    Assuming that your sample data is in A2:C6, headers in A1:C1. Try this formula in D2, then fill down

    =IF(B2="parent","",IF(B1="child",D1,A1))

    If both parents are listed above a child then you will get the ID from the second parent.

  6. #6
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Parent Child relationship issue: Get parent ID for child

    Quote Originally Posted by AliGW View Post
    Ins Deutsche übersetzt:

    =WENNFEHLER(WENN(B2="Child";VERWEIS(2;1/(B$2:B2="Parent");A$2:A2);"");"")
    You missed a bit in the translation, Ali

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2502 (Windows 11 Home 24H2 64-bit)
    Posts
    89,559

    Re: Parent Child relationship issue: Get parent ID for child

    OK:

    =WENNFEHLER(WENN(B2="Kind";VERWEIS(2;1/(B$2:B2="Elternteil");A$2:A2);"");"")

    Ich bin Deutschlehrerin.

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2502 (Windows 11 Home 24H2 64-bit)
    Posts
    89,559

    Re: Parent Child relationship issue: Get parent ID for child

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

  9. #9
    Registered User
    Join Date
    08-28-2018
    Location
    Germany
    MS-Off Ver
    Office 365
    Posts
    3

    Re: Parent Child relationship issue: Get parent ID for child

    works perfect. Thanks

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2502 (Windows 11 Home 24H2 64-bit)
    Posts
    89,559

    Re: Parent Child relationship issue: Get parent ID for child

    Bitte schön.

+ 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] Looking up all the child values associated with one parent value
    By cwwazy in forum Excel General
    Replies: 7
    Last Post: 08-03-2015, 04:09 PM
  2. [SOLVED] Sorting with Parent and Child
    By dominict in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-04-2013, 06:56 AM
  3. [SOLVED] Parent child relationships(working out parent item) for each item
    By grphillips in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 03-21-2013, 05:58 AM
  4. Parent Child Relationship
    By Automation Guru in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-02-2013, 04:48 AM
  5. Parent Child Macro
    By ckattookaran in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-06-2012, 11:50 AM
  6. Replies: 4
    Last Post: 08-30-2009, 03:43 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