Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Hierarchy issue

Hi all,

I have a table which contains the following fields:

NodeIDParentID
11
21
22
33
43
44
55

As you can see here are four types of records:

- Real children (having a valid parentID, which is not their own NodeID)

- Real parents (having their own NodeID used as ParentID in another record)

- "Fake" children (Having their own NopdeID as ParentID, but have no children themselves)

- Records without children (Having their NodeID as ParentID, but have neither any parents or children)

My problem:How can I display the hierarchy of the data above withion a table, having two columns: Parents and Children showing in the parents column the parents name and in the childrens column the corresponding childrens name ?

I have attached a little sample file - maybe someone can help me out here.

Thanks in advance,

K

4 Replies
ToniKautto
Employee
Employee

By setting the [ParentName] parameter to a string you will get a field with the parent's name in your data table.

Also if you add the NodeName as the [PathSource] in combination with naming the 'NodeTree' you will get one field with the hierarchy path, which you then can add in a List Box that can present the hierarchy as TreeView (List Box Properties > General tab) based on the seprator you have defined.

Recommendation is that you try a Hierarchy call like this for example;

Hierarchy (NodeID, ParentID, NodeName, 'ParentName', NodeName, 'TreeView', '/')

When building hierarchies it is highly recommended that you set the top nodes to have a common parent node, in this case the 'Real parents' could have 0 as their parent ID, to make it clear for QlikView how all nodes belong together. Keep in mind that with the Hierarchy function the intention is to build a hierarchy tree, which is a structure where all node should be linked to an other node. This means that giving nodes their own ID as their parent ID will actually not map them in the structure. It maybe would be wiser to create fake node to link these to if you do not want them visible on the top node level.

Finally in this case you should drop the nodes table or rename the fields so that you do not get the synthetic key. Please find an example attached below.

Not applicable
Author

Hi Kalin,

Here is the sample attachment for creating treeview.

Hope it may helps you.

Regards

Not applicable
Author

Thanks for the feedback, Toni.

Unfortunately i have to deal wioth the data source as it is - is there a way to accomplish what i want with the the source data as i provided it in my example ?

Thanks a lot.

K

ToniKautto
Employee
Employee

I understand that you have a specific formatting and structure in your source data, but generally when working in QlikView you need to rework the data so that it fits to a data model that you have made designed in QlikView.

In your source data you have obviously found a way to tag you data and its meaning, and I am not questioning that in any way. What I am trying to say is however that in QlikView you should transfer the data so that you utilize QlikView in a good way and at the same time without altering the actual values of your data. This is a general principle of loading datat to QlikView and is not only for this type of scenario.

In my suggested solution you see that the partens are still identifiable and the children are correctly connected, as well as the orphans. This is really what QlikView is for in general, load you existing data and structure it in a data model that allows you to analyse it.