Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
I think you can use the HIERARCHY resp. HIERARCHYBELONGSTO LOAD prefixes to create a model that serves your need.
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)
Please post a small qlikview document that illustrates the problem.
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.
I think you can use the HIERARCHY resp. HIERARCHYBELONGSTO LOAD prefixes to create a model that serves your need.
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)
Thanks, Stefan! Works perfectly fine!