Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
nikhilgarg
Specialist II
Specialist II

What is Hierarchy() ?

Hello,

Can any one tell me the use of Hierarchy() with an example. In help content i cannot guess much about it.

tHanks

4 Replies
Gabriel
Partner - Specialist III
Partner - Specialist III

Hi,

This resource might help http://community.qlik.com/docs/DOC-4823


petter
Partner - Champion III
Partner - Champion III

Hierarchies is an excellent example with data from Henric Cronström

Unbalanced, n-level hierarchies is an even more extensive treament of the subject.

simospa
Partner - Specialist
Partner - Specialist

If you have this:

NodeIDParentIDEmployeeRole
1BrianGlobal Manager
21PaulRegional Manager
31ClareRegional Manager
42StephenCountry Manager
53JohnCountry Manager
63DavidCountry Manager
74BernhardSenior Sales
85MarkSenior Sales
96PamelaSenior Sales
106SusanSenior Sales
119SeanJunior Sales
129TerryJunior Sales

You can obtain a structure like this:

NodeIDParentIDEmployeeRoleParentDescPathLevel
1BrianGlobal ManagerBrian1
21PaulRegional ManagerBrianBrian/Paul2
31ClareRegional ManagerBrianBrian/Clare2
42StephenCountry ManagerPaulBrian/Paul/Stephen3
53JohnCountry ManagerClareBrian/Clare/John3
63DavidCountry ManagerClareBrian/Clare/David3
74BernhardSenior SalesStephenBrian/Paul/Stephen/Bernhard4
85MarkSenior SalesJohnBrian/Clare/John/Mark4
96PamelaSenior SalesDavidBrian/Clare/David/Pamela4
106SusanSenior SalesDavidBrian/Clare/David/Susan4
119SeanJunior SalesPamelaBrian/Clare/David/Pamela/Sean5
129TerryJunior SalesPamelaBrian/Clare/David/Pamela/Terry5

or, if you specify more parameters:

NodeIDParentIDEmployeeRoleParentDescEmployee1Employee2Employee3Employee4Employee5PathLevel
1BrianGlobal ManagerBrianBrian1
21PaulRegional ManagerBrianBrianPaulBrian/Paul2
31ClareRegional ManagerBrianBrianClareBrian/Clare2
42StephenCountry ManagerPaulBrianPaulStephenBrian/Paul/Stephen3
53JohnCountry ManagerClareBrianClareJohnBrian/Clare/John3
63DavidCountry ManagerClareBrianClareDavidBrian/Clare/David3
74BernhardSenior SalesStephenBrianPaulStephenBernhardBrian/Paul/Stephen/Bernhard4
85MarkSenior SalesJohnBrianClareJohnMarkBrian/Clare/John/Mark4
96PamelaSenior SalesDavidBrianClareDavidPamelaBrian/Clare/David/Pamela4
106SusanSenior SalesDavidBrianClareDavidSusanBrian/Clare/David/Susan4
119SeanJunior SalesPamelaBrianClareDavidPamelaSeanBrian/Clare/David/Pamela/Sean5
129TerryJunior SalesPamelaBrianClareDavidPamelaTerryBrian/Clare/David/Pamela/Terry5

It's very useful to provide structure related to parent-child.

The script used for my example is:

Hier:

Hierarchy(NodeID, ParentID, Employee,

ParentDesc, Employee, Path, '/', Level)

LOAD NodeID,

     ParentID,

     Employee,

     Role

FROM

foo.xlsx

(ooxml, embedded labels, table is Sheet1);

You can use the wizard when importing a Table file (select the file, then click twice "Next").

You can refer to user guide to better understand the list of parameters.

Let us know.

S.

thiago_mlg
Creator II
Creator II

NikHil, look my Document about it.

HIERARCHY - DESCRIPTION

It is very detailed.

Thiago Gonçalo