Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
myhanlam
Contributor
Contributor

Get all descendants of each parent

Hi all,

I need to find all descendants of each element in the parent column. First, my data contains 2 columns, 1 is the parents and the other is children. No levels are specified. 

As illustrated in the picture, I need to transform the table on the left into the table on the right. Which means for each parent, I will need to get every of their descendants next to them.

Is there a way to do this in QLIK Sense? 

Thanks!

myhanlam_1-1665400931459.png

 

 

Labels (1)
1 Solution

Accepted Solutions
MarcoWedel

 

one example using the HierarchyBelongsTo prefix:
https://help.qlik.com/en-US/sense/August2022/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptPrefix...

 

table1:
HierarchyBelongsTo (Child,Parent,Descendant,Ancestor,AncestorName,DepthDiff)
LOAD *,
     Child as Descendant
INLINE [
    Parent, Child
     , A
    A, B
    A, C
    A, D
    A, E
    B, F
    B, G
    B, H
    C, I
    C, K
    D, L
    F, M
    F, N
    F, O
];

 

MarcoWedel_0-1665432112201.png

 

View solution in original post

3 Replies
Mark_Little
Luminary
Luminary

MarcoWedel

 

one example using the HierarchyBelongsTo prefix:
https://help.qlik.com/en-US/sense/August2022/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptPrefix...

 

table1:
HierarchyBelongsTo (Child,Parent,Descendant,Ancestor,AncestorName,DepthDiff)
LOAD *,
     Child as Descendant
INLINE [
    Parent, Child
     , A
    A, B
    A, C
    A, D
    A, E
    B, F
    B, G
    B, H
    C, I
    C, K
    D, L
    F, M
    F, N
    F, O
];

 

MarcoWedel_0-1665432112201.png

 

myhanlam
Contributor
Contributor
Author

This solution works well for me. Thanks Marco!