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

Hierarchy: count sub-levels

Hi,

I have two tables: the first one is call CATEGORY and essentially represents a 5 levels tree of categories; the second one is called REQUEST_DETAIL and is a list of records each one categorized using the categories defined in the CATEGORY table.

I loaded the CATEGORY table in qlikview using the HIERARCHY function, so I have the structure of the categories split in different levels and the depth of each category.

When I select  depth = 1 (all the roots of the tree) I would like to count in the second table not only the number of records corresponding to the selected categories but even the number of records correspoding to the sons of the selected roots.

Same thing if i select depth = 2 (in this case all roots will be excluded) and so on.

It's 2 days that i'm trying to find a solution to this problem, can anyone help me?

Here' s an extract of the tables:

CATEGORY

CATEGORY_IDCATEGORY_NAMEFATHER_ID
1A
2B1
3C1
4D3
5E4
6F4

DEPTH     TREE STRUCTURE

1                              A

2                         B       C

3                                      D

4                                   F     E

REQUEST_DETAIL

IDCATEGORY_ID
11
22
33
42
55
66
75
85

So, counting the number of records with the same category i have:

A = 1 time

B = 2

C = 1

D = 0

E = 3

F = 1

If I select DEPTH = 1 I shoud see:

A = 1+2+1+0+3+1

If I select DEPTH = 2:

B = 2 and C = 1+0+3+1

DEPTH = 3:

D = 0+3+1

DEPTH = 4:

E = 3 and F = 1

Thanks in advance.

7 Replies
Not applicable
Author

Any ideas?

Not applicable
Author

Hi,

you need to load your category with HierarchyBelongsTo().

regards

Darek

Not applicable
Author

Andreo,

let me know if you need more help ....

regards

D

Not applicable
Author

Hi Darek,

thanks to your indication, i stumbled upon this video:

http://www.youtube.com/watch?v=ywz8WNitL1k

that clarified me the difference between Hierarchy and HierarchyBelongsTo.

I solved the problem loading with Hierarchy and creating a pivot table that allows to expands from level 1 to level 5.

Is it possible to graph what i see in the pivot table? (if I simply switch from pivot to linear chart the graph counts only the Leaves correspondig to the selected level)

Thanks,

Andreos

Not applicable
Author

Hi Andreos. I have a similar problem. Could you share your QVW with the solution, if you still have it?

Thanks,

Luciano

Not applicable
Author

HI Luciano,

I'm sorry I can't share the document since it contains reserved information of my company.

Anyway I can confirm what I did, I create a pivot table with the levels as dimensions and the data you want to count as expression and I left the levels expandable. If you expand level 1 you see the count of level 2,3,4 and 5 and so on.

I hope this can help you.

Regards.

Not applicable
Author

Thanks for reply.

I watched the video you suggested and I'll try the same what you've done.

Regards.

2016-12-15 7:56 GMT-02:00 Nicola Sardone <qcwebmaster@qlikview.com>: