Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Something is going wrong with function Hierarchy

Hello,

Maybe I am missing something but I did not find the solution and need help.

My table DATA have the property : one child have only one parent. One parent can have several children.

I am using function Hierarchy like below :

Hierarchy( id, parentid, node,,node,TreeView) Load

id, parentid, node
Resident DATA;

The result I have on 'TreeView'  is currently :

Root

Root/

Root//

Root///

Root////

Root/////

Root//////

Root///////

and I expected :

Root

Root/123

Root/123/95548

......

Many thanks in advance for your help

Regards

Gilles

1 Solution

Accepted Solutions
hic
Former Employee
Former Employee

I found three problems:

1) The data model is not good. See picture. The field "node" should exist in only one table.

2) You should have the root nodes as records of their own in the input to the Hierarchy prefix. The parent of a root should be NULL.

3) For some reason, the path is not generated correctly if the node names are numeric. This could be a bug and this is what causes your problem. But the work-around is simple: Use the Text() function for the node names.

Model.jpg

In the attachment you can see that it works if you make these changes.

HIC

View solution in original post

4 Replies
hic
Former Employee
Former Employee

I need to see your data to figure out where the problem is. My example (see attachment) works fine.

HIC

Not applicable
Author

Hello Henric,

please find in attachment my application (restricted data, deleted connection).

I noticed that then I use an infile it is working but I need to call the table directly from the database.

Many thanks in advance for your help,

Regards,

Gilles

hic
Former Employee
Former Employee

I found three problems:

1) The data model is not good. See picture. The field "node" should exist in only one table.

2) You should have the root nodes as records of their own in the input to the Hierarchy prefix. The parent of a root should be NULL.

3) For some reason, the path is not generated correctly if the node names are numeric. This could be a bug and this is what causes your problem. But the work-around is simple: Use the Text() function for the node names.

Model.jpg

In the attachment you can see that it works if you make these changes.

HIC

Not applicable
Author

Thank you very much for the explanations.

It is working now

Regards,

Gilles