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: 
m_baroja
Partner - Contributor III
Partner - Contributor III

Hierarchy_Belongs_To shouldn't do this?

Hi,

I send you a very simple dataset.

  

PARENTCHILD
NG04241DE00PAL002
NG04241DE00BOL006
NG04241DE00INC038
NG04241DE00NG04241DI00
NG04241DI00CAJ001
NG04241DI00PA46NG000

As you can see, it's a 3 level tree: NG04241DE00 is root, and then all are final nodes except NG04241DI00, which has two final nodes below.

What I want is a table like this:

 

ANCESTORCHILD
NG04241DE00PAL002
NG04241DE00BOL006
NG04241DE00INC038
NG04241DE00NG04241DI00
NG04241DE00CAJ001
NG04241DE00PA46NG000

This table shows the root and all of the nodes below, even the children of NG04241DI00.

I thought Hierarchy_Belongs_To should solve this situation, but it doesn't show the children of NG04241DI00, just:

ANCESTORCHILD
NG04241DE00PAL002
NG04241DE00BOL006
NG04241DE00INC038
NG04241DE00NG04241DI0


The way I am using the function is: HierarchyBelongsTo(child_id,parent_id,child_name,'Ancestor ID','Ancestor')

Am I maybe using wrongly that function? Any ideas?

Thanks!

1 Solution

Accepted Solutions
m_baroja
Partner - Contributor III
Partner - Contributor III
Author

In my data I was missing the "parentless child" for the root!!

Thanks!

View solution in original post

3 Replies
Chanty4u
MVP
MVP

or tryng in listbox?

if yes

u can Tick   Show as tree view with  seperator

Gysbert_Wassenaar

Works for me:

HierarchyBelongsTo(CHILD,PARENT, CHILDNAME, 'AncestorID','AncestorName', Depth)

LOAD PARENT,CHILD, CHILD as CHILDNAME INLINE [

PARENT,CHILD

, NG04241DE00

NG04241DE00, PAL002

NG04241DE00, BOL006

NG04241DE00, INC038

NG04241DE00, NG04241DI00

NG04241DI00, CAJ001

NG04241DI00, PA46NG000];


talk is cheap, supply exceeds demand
m_baroja
Partner - Contributor III
Partner - Contributor III
Author

In my data I was missing the "parentless child" for the root!!

Thanks!