You are on page 1of 11

QlikView How to Guide

Qlikview TreeView

Description: BISP is committed to provide BEST learning material to the beginners and advance learners. In the same series, we have prepared a complete end-to end Hands-on Beginners G ide !or "li#view implementation. The doc ment !oc ses on How to Series $%or#ing with Tree&iew'. (oin o r pro!essional training program and learn !rom e)perts.

Histor*+ &ersion ,escription -hange /.0 Initial ,ra!t /.0 2eview30

. thor S rbhi Sah .mit Sharma

P blish ,ate 10st . g 1/01 th 14 . g 1/01

www.bispsolutions.com

www.bisptrainigs.com

www.hyperionguru.com

Page 0

Table of Contents
Table o! -ontents...............................................................................................................................................................1 The "li#&iew Treeview.....................................................................................................................................................5 E)panding a hierarch*........................................................................................................................................................5 Hierarch*67 ! nction.......................................................................................................................................................8 The tree-view list-bo)........................................................................................................................................................9 Hierarch*BelongsTo67 ! nction....................................................................................................................................0/

www.bispsolutions.com

www.bisptrainigs.com

www.hyperionguru.com

Page 1

The QlikView Treeview


:or implementing Treeview in the an* "li#&iew app !irstl* we have to achieve hierarch* which disc ssed in the below proced re.

Expanding a hierarchy
The hierarchical nat re o! the table allows one val e to be related to one or more val es across the table, as a parent or as a child. In !act, one val e can be related to one or more other val es as a child and to one or more other di!!erent val es as a parent. The advantage o! these tables is that the* #eep the in!ormation in a compact !ormat, and "li#&iew is able to handle them, and e)pand its relations with a special ! nction+ Hierarch*. In technical terms, the original table !ormat is called an .d;acent <odes table, while the res lting table is called an E)panded <odes. Some hierarchies are implied, li#e the bi= ito s calendar with >ear -?" arter-?@onth-?,a*, etc. In the case o! the calendar, the hierarch* has levels that we all recogniAe and is t*picall* stored in a denormaliAed table with a row !or each val e at the lowest level 6sa* ,a*7 and a col mn with repeating val es !or each higher level in the calendar hierarch* 6@onth, " arter, >ear, etc.7. %e have given a table Hirarch* E)ample.

In this table B title !ields are available. In which %orld, continent ,co ntr* and cit* name are present. we want to achieve the hierarch* as %orld C ?-ontinent C ?-o ntr* C?-it* !or achieving this hierarch* we will !ollow these steps. Step 07:irstl* create the new application and give the name Hierarch*.=vd. Step 17Then go to the -?script editor and clic# on the option table !iles.

www.bispsolutions.com

www.bisptrainigs.com

www.hyperionguru.com

Page 5

Step 57-hoose the !ile Hierarch* e)ample and then open it.

Step B7Then the table wiAard will open, chec# the Dabels it sho ld be Embedded labels. Then-?<e)t

www.bispsolutions.com

www.bisptrainigs.com

www.hyperionguru.com

Page B

Step E7<ow clic# on the -?<e)t. Then choose the Hierarch* option.

www.bispsolutions.com

www.bisptrainigs.com

www.hyperionguru.com

Page E

These are the !ields contained b* the Hierarch* parameter. ID Field: This is the !ield that stores the I,s corresponding to the child nodes Parent ID Field+ This is the !ield that stores the I, o! the parent node. Name ield: This is the !ield that stores the name o! the child node. Parent Name: This is a string sed to name a new !ield that will be created containing the names o! the parent nodes. Pat! Name: This is a string sed to name a new !ield that will be created containing the list o! nodes !rom the top level to the corresponding node. Dept! Name: This is the name to be assigned to a new !ield that will hold the n mber o! levels !or each e)panded node. Pat! "ource: This is the !ield !rom the so rce table that contains the val e that sho ld be sed to pop late the hierarch* path. Pat! Delimiter: This de!ines the string that sho ld be sed to separate the hierarch* val es in the path. -?Then clic# o# Step F7 Then the script will be added in the script editor. Here the HIE2.2-H> ! nction comes de!a lt with the script this had come beca se we have sed the hierarch* ! nction via !ile wiAard.

www.bispsolutions.com

www.bisptrainigs.com

www.hyperionguru.com

Page F

Give the Hierarch*Table in the place o! Hierarch*.

Hierarchy() function
The Hierarch*67 ta#es these parameters. Hierarc!# $ <odeI,, ParentI,, <ode<ame, GParent<ameH, GPathSo rceH, GPath<ameH, GPath,elimiterH, G,epthH % NodeID CThis !ield ta#es <ame o! the !ield that contains the node id. This !ield m st e)ist in the inp t table here <odeI, is -hildII,. ParentID C This !ield ta#es name o! the !ield that contains the node id o! the parent node this is ParentII,. NodeName C This !ield ta#es the name o! the !ield that contains the name o! the node as child is ta#en. ParentName C . string sed to name the new Parent<ame !ield. I! omitted, this !ield will not be created. I! the !ield name has spaces or special characters then it needs to be in brac#ets or single = otes . Pat!"ource & <ame o! the !ield that contains the name o! the node sed to b ild the node path. This parameter is optional. Here path so rce is child. Pat!Name & . string sed to name the new Path !ield, which contains the path !rom the root to the node. It is an Jptional parameter. I! omitted, this !ield will not be created. I! the !ield name has spaces or special characters then it needs to be in brac#ets or single = otes. Path name is Path ta#en. Pat!Delimiter C . string sed as delimiter in the new Path !ield. Jptional parameter. I! omitted, KL will be sed. I! a single character is provided then the parameter val e does not need to be in single = otes. Dept! C . string sed to name the new ,epth !ield, which contains the depth o! the node in the hierarch*.It is Jptional parameter. Step 87<ow Save the setting and reload Then go to the table viewer.

Here the table is created with the name o! Hirarch*Table. Then go to the Preview option.

www.bispsolutions.com

www.bisptrainigs.com

www.hyperionguru.com

Page 8

I! an* o! the optional parameters are le!t blan#, the new !ield that ses the missing parameter will not be created when e)panding the hierarch* the res lting e)panded nodes table has one !ield !or each hierarch* level, and one record !or each node. .dditionall*, new !ields have been created to show Path and ,epth in!ormation. I! one node has m ltiple parents, the e)panded nodes table will have several records !or these nodes and the e)panded nodes table will e)cl de an* orphan nodes, that is, nodes that have no connection to a top-level node. Jnl* nodes connected to the highest hierarch* level will be #ept in the !inal table. Jnce we have a table with this str ct re, it is eas* to se it on the !rontend o! the "li#&iew doc ment, !or e)ample, within a pivot table or in a hierarch* dimension gro p. %e can implement this hierarch* in the !orm o! list bo) b* sing the tree-view list-bo).

The tree-view list-box


. tree-view list bo) is good at representing hierarchical levels, and provides an eas* wa* to collapseLe)pand the hierarch* with the pl s and min s icons to the le!t o! each parent val e. %ith the res lting data !rom the above e)ample, we will create a new list-bo) ob;ect b* !ollowing these steps+ Step 07Go to the sheet-?<ew sheet ob;ect -?Dist bo) Step 17Then the window will open give the title name as Tree&iew -?Scroll down the !ield option and choose the path in the !ield option. -?-hec# the option Show as Tree&iew this will create the tree str ct re in the listbo) Then-?o#

www.bispsolutions.com

www.bisptrainigs.com

www.hyperionguru.com

Page 9

Step 57Then the new list bo) will be created. Here we are ta#ing advantage o! the hierarchical path created in one o! the !ield. The tree-view list bo) onl* re= ires a !ield with the hierarchical de!inition !or a set o! val es, and with each hierarchical level separated b* a speci!ic character. The separation s*mbol can be an* character.

.!ter this e)plore the list bo) and create new list bo) witho t sing the chec#ed Show as Tree&iew option.

>o can see here the di!!erence between both the listbo)es. See the !irst list bo) created having ver* comple) t*pe str ct re b t in the second list bo) it has simplest str ct re.

www.bispsolutions.com

www.bisptrainigs.com

www.hyperionguru.com

Page 4

HierarchyBelongsTo() function
The Hierarch*67 can be sed !or creating a table that can be sed to drive pivot tables or drill gro ps b t it isnt appropriate !or searching or selecting beca se the ancestors or a node are in separate !ields. Here the Hierarch*BelongsTo67 load ta#es place. It also loads !rom the ad;acenc* list table. It creates a table with all o! the ancestors o! a node in a single col mn. Here is the s*nta) !or the Hierarch*BelongsTo67 load . Hierarc!#'elon(sTo$ <odeI,, ParentI,, <ode<ame, .ncestorI,, .ncestor<ame, G,epth,i!!H % NodeID C The name o! the !ield that contains the node id. This !ield m st e)ist in the inp t table It is named as -hildII, in the table Hierarch*.ncector. ParentID C The name o! the !ield that contains the node id o! the parent node it is sed as ParentII,. NodeName C The name o! the !ield that contains the name o! the node. It is the Parent<ame. )ncestorID C . string sed to name the new ancestor id !ield, which contains the id o! the ancestor node and the id is sed as Parent<ame. )ncestorName C . string sed to name the new ancestor !ield, which contains the name o! the ancestor node. Dept!Di C . string sed to name the new ,epth,i!! !ield, which contains the depth o! the node in the hierarch* relative the ancestor node.It is optional parameter. I! omitted, this !ield will not be created.

.nd we have #ept two !ields in o r Hierarch*.ncector table, These !ields are ta#en which are ParentII, and childII,. we have renamed the childII, !ield thats wh* the s*nthetic #e* is not created. %e are !etching these records !rom the table Hirarch*Table. Then save the table and reload.

The whole script is sed in the ! nction as+

HirarchyTable: HIERARCHY(Child_ID, Parent_ID, Child, ParentName, Child, Path, '-' LOAD Parent_ID, Child_ID, Parent,
www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 0/

Child !R"# $Hierarchy e%am&le'%l() (bi**, embedded label(, table i( $+heet,-) . HierarchyAncect/r: HIERARCHY0E1"N2+T"(Child_ID, Parent_ID,ParentName, ParentName,Ancect/rName LOAD Parent_ID, Child_ID a( ChildID Re(ident HirarchyTable.

www.bispsolutions.com

www.bisptrainigs.com

www.hyperionguru.com

Page 00

You might also like