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

Working with hierarchies

Hi,

I have created a hierarchie (geo type) in Qlickview:

This is the file:

jerar1.png

ans this is the script:

Jerarquia_pais:

Hierarchy(cod_geo, cod_padre, desc_geo, desc_padre, desc_geo, jerarquia_geografica , '|', profundidad) LOAD

cod_geo,

cod_padre,

desc_geo

FROM

(ooxml, embedded labels, table is Hoja1);

Now I have a listbox with the hierarchie working properly:

jerar2.png

the fact table is at low level of the hierarchie (ciudad).

My question:

Now I can only select in the listbox al  the low level (ciudad), is there anyway of selectiong at a higer level (pais)?,  and filtering that rows in the chart (see only data of this selected level)?

for examploe: select España and see data of: Madrid, Sevilla, Valencia, Zaragoza...

Thanks in advance.

4 Replies
Gysbert_Wassenaar

I think you're looking for the HierarchyBelongsTo function instead of the Hierarchy function. You can find an explanation in this blog post: Unbalanced, n-level hierarchies


talk is cheap, supply exceeds demand
Anonymous
Not applicable
Author

Thanks Gyspert,

Now I have created a HierarchyBelongsto.

Jerarquia_pais2:

HierarchyBelongsto (cod_geo, cod_padre, desc_geo, cod_padre, desc_padre, nivel)

LOAD

cod_geo,

cod_padre,

desc_geo

FROM

(ooxml, embedded labels, table is Hoja1);

My problem now: how can I make a listbox od treeview typw with this hierarchy??

I needd, something like:

jerar3.png

Thanks in advance!!

petter
Partner - Champion III
Partner - Champion III

Here is a clipping from Henric Cronström's excellent article about Hierarchies

that shows probably what you are looking for. You need to have a Path with some kind of separator which you can specify - like for instance a / 

2015-05-16 #1.PNG

Gysbert_Wassenaar

You can link your Jerarquia_pais2 hierarchybelongsto table with another table created with the hierarchy function. See the Treebridge and Trees table in the attached example. The Trees table contains a Treepath field that is used in a listbox to select a district. In the pivot table this district and the underlying districts are shown.

Note, there's also a way to select entire subtrees without a hierarchybelongsto table. First collapse the parent of the subtree you want to select and then select the parent node of that subtree. If you then expand it you'll see that the nodes below it are also selected. If you expand the node first and then select it only the node itself will be selected.

comm164279.png


talk is cheap, supply exceeds demand