Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Solving the Informatica Dilemma: On-Demand Briefing - Watch On Demand!
cancel
Showing results for 
Search instead for 
Did you mean: 
ceciliafujita
Contributor III
Contributor III

hierarchy in the same column

i have fathers and children in the same column. Father has the cod_name's lenght smaller than children's. How can i do the relationship between them?

what i have:

codname
1234bla bla bla 1
89732738bla bla bla 2
87852030bla bla bla 3
98934796bla bla bla 4
9876bla bla bla 5
76656453bla bla bla 6
76611453

bla bla bla 7

what i want:

cod

father
1234bla bla bla 1
9876bla bla bla 5
codchildren
89732738bla bla bla 2
87852030bla bla bla 3
98934796bla bla bla 4
76656453bla bla bla 6
76611453

bla bla bla 7

(till ther i know how to do)

relatioship:

fatherchildren
123489732738
123487852030
123498934796
987676656453
9876

76611453

Have anyone any tip?

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Something like this:

T1:

LOAD *,

if(len(cod)>=len(previous(cod)),alt(peek(parent),previous(cod))) as parent INLINE [ 

    cod, name

    1234, bla bla bla 1

    89732738, bla bla bla 2

    87852030, bla bla bla 3

    98934796, bla bla bla 4

    9876, bla bla bla 5

    76656453, bla bla bla 6

    76611453, bla bla bla 7

];

Replace the inline load with a load statement that load your data.


talk is cheap, supply exceeds demand

View solution in original post

6 Replies
Not applicable

Hi,

How do I know that 9876 is the father of 76611453?

Rebeca

ceciliafujita
Contributor III
Contributor III
Author

Because of the original order. The children always come after the father, but not directly at the subsequent line.

Thats my problem to do the relatioship... 😕

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     Have a look at the attachment.

     Hope this is what you want.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Something like this:

T1:

LOAD *,

if(len(cod)>=len(previous(cod)),alt(peek(parent),previous(cod))) as parent INLINE [ 

    cod, name

    1234, bla bla bla 1

    89732738, bla bla bla 2

    87852030, bla bla bla 3

    98934796, bla bla bla 4

    9876, bla bla bla 5

    76656453, bla bla bla 6

    76611453, bla bla bla 7

];

Replace the inline load with a load statement that load your data.


talk is cheap, supply exceeds demand
ceciliafujita
Contributor III
Contributor III
Author

Hello Kaushik,

In your solution i have to describe all the relationship, and that's my problem... what i need is how to automate the relationship.

ceciliafujita
Contributor III
Contributor III
Author

Hello Gysbert, you solved it!

Really thanks!