Hierarchy function easy and Efficient with example---

    First the Hierarchy function consists of following parameters:

    Hierarchy (NodeID, ParentID, NodeName, [ParentName], [PathSource], [PathName], [PathDelimiter], [Depth]) (loadstatement | selectstatement)

    Here is a quick description of each of the parameters:

    NodeID - is the name of the field that contains the node id.

    ParentID - is the name of the field that contains the node id of the parent node.

    NodeName - is the name of the field that contains the name of the node.

    ParentName - is a string used to name the new ParentName field. If omitted, this field will not be created.

    PathSource - is the name of the field that contains the name of the node used to build the node path. This is an optional parameter. If omitted, NodeName will be used.

    PathName - is a string used to name the new Path field, which contains the path from the root to the node. This is an optional  parameter. If omitted, this field will not be created.

    PathDelimiter - is a string used as delimiter in the new Path field. This is an optional parameter. If omitted, ‘/’ will be used.

    Depth - is a string used to name the new Depth field, which contains the depth of the node in the hierarchy. This is an optional parameter. If omitted, this field will not be created.

     

     

    I am taking an organization structure data as an example to explain the Qlikview hierarchy.

     

    ORGANIZATION:

    LOAD * INLINE [

        ROLE, REPORTINGMANAGER, LEVELOFBUSINESSHEAD

        Trainee, Manager, VP

        Junior Consultant, Manager, VP

        Consultant, AsstManager, VP

        Senior Consultant, AsstManager, VP

        AsstManager, VP, DeliveryHead

        Manager, VP, DeliveryHead

        VP, DeliveryHead, Chairman

        DeliveryHead, CEO, Chairman

    ];

     

     

     

    and declare the hierarchy as below

     

    TREE_VIEW:

    LOAD Distinct ROLE as VALUE, ROLE & '-ROLE' as NODE_ID, REPORTINGMANAGER & '-REPORTINGMANAGER' as PARENT_NODE_ID resident ORGANIZATION;

    LOAD Distinct REPORTINGMANAGER as VALUE,REPORTINGMANAGER & '-REPORTINGMANAGER' as NODE_ID, LEVELOFBUSINESSHEAD & '-LEVELOFBUSINESSHEAD' as PARENT_NODE_ID resident ORGANIZATION;

    LOAD Distinct LEVELOFBUSINESSHEAD as VALUE,LEVELOFBUSINESSHEAD & '-LEVELOFBUSINESSHEAD' as NODE_ID,  LEVELOFBUSINESSHEAD & '-LEVELOFBUSINESSHEAD' as PARENT_NODE_ID resident ORGANIZATION;

     

     

    HIERARCHY_TABLE:

    Hierarchy(NODE_ID_H,PARENT_NODE_ID_H, ID, PARENT_NAME, NAME, Organization_Structure) load

    NODE_ID,

    NODE_ID as NODE_ID_H,

    PARENT_NODE_ID as PARENT_NODE_ID_H,

    VALUE as ID,

    VALUE as NAME

    resident TREE_VIEW;

     

     

    After reloading create a list box with the properties as same as the below image

     

     

    Heirarchy.png

     

    Don't forget to select the show as tree view check box.

     

    now you will get the tree view of hierarchy as below image

     

     

    Tree View.png

     

    you can display the values in waterflow,pivot,straight table etc

     

    Thanks