Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
dhavalvyas
Contributor III
Contributor III

Hierarchy

Hi,

I am trying to develop hierarchy in one of the application.The hierarchy user want is,

level ->positiontype->employeeid

In hierarchy we can enter just field name,but in my application there is seprate fields for each level i.e. for level 0 different field,level 1 different field.so how it is possible to do hierarchy ?

Sample example raw data I have attached as below.

As you can see ion raw data i attached below you will get idea for level fields.

2 Replies
jaume_soc
Contributor II
Contributor II

Try unpivoting the table:

https://help.qlik.com/en-US/sense/3.2/Subsystems/Hub/Content/LoadData/work-with-cross-tables.htm

I think this lik might help you. In the end you have to transform that so that you get something like this:

 

employeeidpositiontypelevel(value)
1e101345
1e113445
1e128754
1e132345
1e146564
1e155647
2e202321
2e216754
2e226787
2e231345
2e241345
2e251234

....

you have another field (level) which contains the other 6 fields (level 0 to 5)

hari8088
Creator
Creator

use below script or find the attached qvw.

Data:

CrossTable(Levels,Data,2)

LOAD employeeid, positiontype, level0, level1, level2, level3, level4, level5

FROM (ooxml, embedded labels, table is Sheet1);

Hierarcy:

LOAD Levels&'_levels' as value,Levels&'_levels' as nodeid,Levels&'_levels' as parentid Resident Data;

LOAD positiontype&'_positiontype' as value,positiontype&'_positiontype' as nodeid,Levels&'_levels' as parentid Resident Data;

LOAD employeeid&'_employeeid' as value,employeeid&'_employeeid' as nodeid,positiontype&'_positiontype' as parentid Resident Data;

final:

Hierarchy(nodeid,Newparentid,id,parentidnew,name,structure)

LOAD

value as id,

value as name,

nodeid,

nodeid as newnodeid,

parentid as Newparentid

Resident Hierarcy;

DROP Table Hierarcy;

DROP Table Data;