Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to create Hierarchy from flat table structure

Hierarchy offered by QlikView seems to work with the fashion of NodeID-ParentID.

We are using flat table structure to define hierarchies. eg -

Product_Level_5,Product_level_4,Product_level_3,Product_level_2,Product_level_1

How do I load this data in "hierarchy" fashion? I am curious to use Tree View List box in QV 9.

I thought QlikView can show data in tree fashion if a "group" is attached to a listbox... But looks like the data itself has to be defined in hierarchical way during the load script..

Appreciate any help.... Thanks!

14 Replies
Not applicable
Author

Maybe this should help

Please refer to the attached file. You should find a hierarchy table. I scripted what you've suggested. However, it doesn't accomplish what I'm expecting. In the example, I'm hoping that when I click on a continent like North America, I would expect everything under the umbrella of North America should be selected/associated. I don't seem to get that functionality. Why?

Not applicable
Author

Hi,

you have to build a loop that you get that structur:

europe

europe/london

europe/london/roman

so for each level there has to be a row.

bye

Roman

suniljain
Master
Master

You have make excelsheet of excelsheet of hierarchy and connect it with data modelling .

Some ERP tool maintaining this type of hierarchy in that manner.

Not applicable
Author

Like this:

Not applicable
Author

Hi,

Today I came across the same problem as you have originally described, however mine was in relation to a customer hierarchy, not a product. In any case, the solution would be the same.

Basically what you need to do is rebuild the parent/child relationship so you can then load using the hierarchy load feature. To do this, I loop through all the possible levels of the hierarchy and create the parent/child relationship between each node. I use distinct to ensure I do not duplicate:


FOR iLevel = 1 TO 9;
LET iChildLevel = $(iLevel) + 1;
TEMP_HIER_TABLE:
LOAD DISTINCT
CUST_CODE_$(iLevel) as PARENT_CUST_CODE,
CUST_CODE_$(iChildLevel) as CHILD_CUST_CODE
RESIDENT STANDARD_HIER
WHERE Not IsNull(CUST_CODE_$(iChildLevel));
NEXT iLevel;
LEFT JOIN (TEMP_HIER_TABLE)
LOAD CUST_CODE as CHILD_CUST_CODE,
CUST_NAME as CHILD_CUST_NAME
RESIDENT CUSTOMER;
HIER_TABLE:
HIERARCHY (CHILD_CUST_CODE, PARENT_CUST_CODE, CHILD_CUST_NAME, PARENT_CUST_NAME, CHILD_CUST_NAME, HIER_PATH, '-')
LOAD CHILD_CUST_CODE,
PARENT_CUST_CODE,
CHILD_CUST_NAME,
CHILD_CUST_CODE AS CUST_CODE
RESIDENT TEMP_HIER_TABLE;
DROP TABLE TEMP_HIER_TABLE;


The STANDARD_HIER table just stores the levels of the hierarchy.

Hope this helps!