PDA

View Full Version : [SOLVED] Build parent/child hierarchy



adygelber
09-23-2016, 04:14 AM
Hello,

I kindly ask for your support because I have to achieve something that seems to be simple but I just can't figure it out how to do it.

Mainly, I have two columns. The first one contains some parent codes, the second one contains some child codes which can consequently become parent codes for other child codes. And so on.

Having this in mind, I want to create a hierarchy like the one form the example file (see attachment). The example file was created manually with a minimum number of records but the final database can be way bigger.

Thank you in advance for your support!
A.B.

Also posted here:
http://www.ozgrid.com/forum/showthread.php?t=201237&p=777920#post777920
http://www.mrexcel.com/forum/excel-questions/966430-build-parent-child-hierarchy.html#post4639220 (http://www.ozgrid.com/forum/showthread.php?t=201237&p=777920#post777920)

Paul_Hossler
09-23-2016, 06:51 AM
So you're looking for something like this?

I made it more into a tree so I could see it clearer, and color coded the nodes for traceabiliry

17148

adygelber
09-23-2016, 07:13 AM
Hey Paul,

If it is easier for you to do it like that, that's fine.
If it is the same, I preffer it in this form:



Parent
Child









AB00000
AB00001

AB00000
AB00001
AB00002
AB00005
AB00009
AB00010


AB00001
AB00002




AB00006




AB00001
AB00003




AB00007




AB00001
AB00004



AB00003
AB00011




AB00002
AB00005



AB00004
AB00008




AB00002
AB00006









AB00002
AB00007









AB00003
AB00011









AB00004
AB00008









AB00005
AB00009









AB00009
AB00010










Thanks!

Paul_Hossler
09-23-2016, 07:34 AM
Your original had 2-5 in three times

Do you want to ignore duplicates or expand each?

17150


Also I assume that a circular reference would be and error?

For example

2-4-5-2

adygelber
09-23-2016, 07:45 AM
Please excuse my mistakes from the original example.
Yes, the duplicates are to be removed and there is also another mistake.

The correct table should be:



Parent
Child









AB00000
AB00001

AB00000
AB00001
AB00002
AB00005
AB00009
AB00010


AB00001
AB00002




AB00006




AB00001
AB00003




AB00007




AB00001
AB00004



AB00003
AB00011




AB00002
AB00005



AB00004
AB00008




AB00002
AB00006









AB00002
AB00007









AB00003
AB00011









AB00004
AB00008









AB00005
AB00009









AB00009
AB00010










Thank you!

adygelber
09-26-2016, 03:45 AM
I received a working answer on MrExcel forum: http://www.mrexcel.com/forum/excel-questions/966430-build-parent-child-hierarchy.html

Maybe someone will need the solution.