Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I have a data set as shown below.
I want to make a tree structure by using Hierarchy function in QV
Niv1 | Niv0 | Name |
1 | 0 | NAME0 |
1N | 1 | NAME1 |
1N11 | 2 | NAME2 |
2 | 0 | NAME02 |
2B | 1 | NAME12 |
2B11 | 2 | NAME22 |
The final resultat :
NAME0
NAME1
NAME2
Please help me.
Many thanks
Maybe use something like
INPUT:
LOAD *, RecNO() as NodeID, If(Niv0=0,NULL(), Peek(NodeID)) as ParentID
INLINE [
Niv1, Niv0, Name
1, 0, NAME0
1N, 1, NAME1
1N11, 2, NAME2
2, 0, NAME02
2B, 1, NAME12
2B11, 2, NAME22
];
Hierarchy(NodeID, ParentID, Name,ParentName,Name, Path)
LOAD NodeID, ParentID, Name
Resident INPUT;
DROP TABLE INPUT;
Then create a listbox with option treeview enabled for field Path:
Your Niv1 and Niv0 fields are not describing parent / child nodes, do they?
Could you describe a bit more detailed the logic / relation of your data?
Field Values Niv0
0 is the top level
1 is the second level
2 is the last level
Hi Said,
Maybe you can start here:
Hierarchy function easy and Efficient with example---
Please let me know if this helps.
Kind regards,
You always have at most a single parent for a node and a single child?
I tried that but not working
yes
Maybe use something like
INPUT:
LOAD *, RecNO() as NodeID, If(Niv0=0,NULL(), Peek(NodeID)) as ParentID
INLINE [
Niv1, Niv0, Name
1, 0, NAME0
1N, 1, NAME1
1N11, 2, NAME2
2, 0, NAME02
2B, 1, NAME12
2B11, 2, NAME22
];
Hierarchy(NodeID, ParentID, Name,ParentName,Name, Path)
LOAD NodeID, ParentID, Name
Resident INPUT;
DROP TABLE INPUT;
Then create a listbox with option treeview enabled for field Path: