Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Micki
Creator
Creator

HIERARCHYBELONGSTO for child items

Hi folks, 

have the following table:

Micki_0-1609774967211.png

I am using function HIERARCHYBELONGSTO() which gives me  correct result all parents of current item,

but how to do the same for Childs item? 

10 Replies
edwin
Master II
Master II

your challenge is when a node is selected, you want to list down all the nodes under it (direct and indirect children?)
when done properly, you can select the parent and all children will be possible selections:

without selection:

edwin_0-1609856004657.png

 

select America:

edwin_1-1609856035464.png

 

HierarchyBelongsTo (NodeID, ParentID, Name, ParentID, ParentName, DepthDiff) LOAD * inline [
NodeID, ParentID, Name
1,,World
20,1,America
79,20, US
85,79, California
90,85,Napa Valley
178,1,Europe
281,178, France
283,281, Bordeaux
];
QFabian
Specialist III
Specialist III

hi @Micki , i recommend you take a look to the  Hierarchy wizard

just recreate your table into a excel or something, to test this wizard :

its apperas at the third 'Next'

QFabian_0-1609858380123.png

 

QFabian
Micki
Creator
Creator
Author

hI, @QFabian , @edwin, thanks for your help, my case most like when i have circular hierarchy(if A have child B and B child C, C child C), do you have any example, or documentation would be very welcomed

edwin
Master II
Master II

@Micki "A have child B and B child C, C child C" is not circular.  if you have specific samples just post it (pls not a picture)

here is the doc for the function its very straight forward:
HierarchyBelongsTo ‒ QlikView

edwin
Master II
Master II

unless you consider C child C as circular.  note that DepthDiff = 0 is the scenario you may be thinking of.  just exclude that

edwin
Master II
Master II

edwin_0-1610038441110.png

 

Micki
Creator
Creator
Author

@edwin , sorry my bad should be  "A has child B , B  has child C,  so A has child C"  

edwin
Master II
Master II

@Micki  that is still not circular.  that is more like a grandchild.  the DepthDiff will identify those.  are you saying you just need direct children?  use DepthDiff=1

edwin
Master II
Master II

if the object is to find the Children of a node, use DepthDiff=1:

edwin_0-1610039554762.png

for America  you get US from above.