Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

owkbtle17
New Contributor

More than one Selfjoin

Hi all,

One table from a database, which has the parent in the same table. But a entry can have more than one parent. It's nowhere defined how many parents, but what I see, should there be not more than 15. How can I get the full path for each entry? At the end I should get for each entry the whole path.

A example from the table

IDpart of pathParent ID
1root
2fruits1
3banana2
4apple2
5yellow3
6vegetables1
7potato6

I need at the end

IDfull path
1root
2root/fruits
3root/fruits/banana
4root/fruits/apple
5root/fruits/banana/yellow
6root/vegetables
7root/vegetables/potato

One self join is no problem, but this... I really need help.

thanks in advance,

Tina

1 Solution

Accepted Solutions
vinieme12
Esteemed Contributor II

Re: More than one Selfjoin

try hierarchy keyword

Hierarchy(ID,ParentID,partofpath)

LOAD * INLINE [

    ID, partofpath, ParentID

    1, root

    2, fruits, 1

    3, banana, 2

    4, apple, 2

    5, yellow, 3

    6, vegetables, 1

    7, potato, 6

];

3 Replies
vinieme12
Esteemed Contributor II

Re: More than one Selfjoin

try hierarchy keyword

Hierarchy(ID,ParentID,partofpath)

LOAD * INLINE [

    ID, partofpath, ParentID

    1, root

    2, fruits, 1

    3, banana, 2

    4, apple, 2

    5, yellow, 3

    6, vegetables, 1

    7, potato, 6

];

vinieme12
Esteemed Contributor II

Re: More than one Selfjoin

owkbtle17
New Contributor

Re: More than one Selfjoin

Thank you very much, it's exactly what I searched.