Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2022, LIVE in Denver CO., May 16-19, 2022. REGISTER NOW TO RECEIVE EARLY BIRD PRICING
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Elements having root-parent element with certain attribute in Listbox

Hi folks,

I currently struggle with the following:

I have a hierachical structure of elements. Each element has an attribute parentID referring to its parent element and an attribute A with possible values X, Y, Z. Elements where the parentID is null, are root elements.

What I want to do, is having a listbox in tree view (so far so good), which contains all root elements having A = X and all its children regardless of their attribute A's value (as sub elements in the tree view).

Tried a couple of different set analyses but couldn't achieve the desired result...

Any help pointing me to a solution for my problem is highly appreciated!

Cheers,

Marvin

1 Solution

Accepted Solutions
swuehl
MVP
MVP

I think you can use the HIERARCHY resp. HIERARCHYBELONGSTO LOAD prefixes to create a model that serves your need.

Hierarchies

Something like

Set NULLINTERPRET = '';

INPUT:

LOAD *, If(Len(Trim(ParentID))=0 and AttributeA = 'A', 1) as Flag INLINE [

ParentID, NodeID, AttributeA, Name

, 1,A, Parent 1

1,2,B, A child

1,3,C, B child

2,4,A, C child

, 5, B, Another parent

5,6, A, D child

];

Hierarchy(NodeID, PID, NodeName, Parent, NodeName, Path)

LOAD ParentID as PID, NodeID, Name as NodeName

RESIDENT INPUT;

HierarchyBelongsTo( NodeID, PID2, Name2, PID2, Ancestor)

LOAD ParentID as PID2, NodeID, Name as Name2

RESIDENT INPUT;

Left JOIN

LOAD NodeID as PID2, Flag as Flag2 RESIDENT INPUT;

Then you can create your list box with the treeview style and filter using Flag2:

=Aggr(Only({1<Flag2 = {1}>}Path), Path)

2016-08-20 23_28_00-QlikView x64 - [C__Users_Stefan_Downloads_comm229627.qvw_].png

View solution in original post

4 Replies
Gysbert_Wassenaar

Please post a small qlikview document that illustrates the problem.


talk is cheap, supply exceeds demand
svinnakota
Creator
Creator

Hello Marvin,

Can you please post the example so that we can try to help you in resolving the issue and try to attach the output which you are looking for.

swuehl
MVP
MVP

I think you can use the HIERARCHY resp. HIERARCHYBELONGSTO LOAD prefixes to create a model that serves your need.

Hierarchies

Something like

Set NULLINTERPRET = '';

INPUT:

LOAD *, If(Len(Trim(ParentID))=0 and AttributeA = 'A', 1) as Flag INLINE [

ParentID, NodeID, AttributeA, Name

, 1,A, Parent 1

1,2,B, A child

1,3,C, B child

2,4,A, C child

, 5, B, Another parent

5,6, A, D child

];

Hierarchy(NodeID, PID, NodeName, Parent, NodeName, Path)

LOAD ParentID as PID, NodeID, Name as NodeName

RESIDENT INPUT;

HierarchyBelongsTo( NodeID, PID2, Name2, PID2, Ancestor)

LOAD ParentID as PID2, NodeID, Name as Name2

RESIDENT INPUT;

Left JOIN

LOAD NodeID as PID2, Flag as Flag2 RESIDENT INPUT;

Then you can create your list box with the treeview style and filter using Flag2:

=Aggr(Only({1<Flag2 = {1}>}Path), Path)

2016-08-20 23_28_00-QlikView x64 - [C__Users_Stefan_Downloads_comm229627.qvw_].png

View solution in original post

Not applicable
Author

Thanks, Stefan! Works perfectly fine!