Qlik Community

QlikView Documents

QlikView documentation and resources.

QlikWorld 2022, LIVE in Denver CO., May 16-19, 2022. REGISTER NOW TO RECEIVE EARLY BIRD PRICING

Recursion Trees.qvw

Showing results for 
Search instead for 
Did you mean: 

Recursion Trees.qvw

This example resolves a recursion tree challenge into an associative data model Recursion means a sequence of predecessor-successor relations, where a child node can repeat in different branches of the tree.

As long as a child node has only "one way up" in the tree, you may sufficiently solve this using our HIERARCHY LOAD or HIERARCHYBELONGSTO LOAD functions.

Although inside the app I called the relations "parent-child", please don't think of it like of a natural child, which by nature has only one mother. In this example, it might have multiple, like B2 and C2 in the below graphics.


The script requires 3 loops and 2 tables to facilitate this and it has a "circular reference" detection to stop execution if wanted. Circular reference happens if a parent repeats further down the tree as a child, which would end in an infinite loop.

There are several parameters to play with (as variables in the load script) togehter with plenty of inline remarks for your understanding.

For example you can set a maximum depth of levels, decide to stop or abort execution upon detecion of a loop, a separator sign for the combined path string ...


Christof Schwarz

Specialist II
Specialist II

awesome ...i just faced this requirement in my exp....i tried alot  at that time ....got something new from you today ...nice job  csw hatsoff...*****

Not applicable

Looks good. Just thinking of an application for this app. I think it would really be helpful in trying to do some sort of a time-variant market basket type analysis say using the sales data. The above visual could be extended to show which bike parts were purchased and in which order. each node could show volume of purchases in absolute and relative terms. Just to clarify that this form of clustering/association is called sequence clustering and is different to the data hierarchies. Maybe this has already been done in QV but am happy to see what the community thinks. Cheers


According to HIC's blog post we can now rely on HIERARCHY LOAD even for this kind of structures.

See the discussion in the blog post. My tests work fine in SR12, but I would be interested if someone has tested HIERARCHY LOAD against real world BoMs?

Bill of Materials

Version history
Last update:
‎2013-12-11 07:23 AM
Updated by: