If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.
Hi everybody,
I'm trying to make a hierarchy tree. I've got a field that contains the complete relation between fathers and sons and each node ID is separated from another by the use of a "/" in this way
/parentID/childID/grandsonID/sonofthegrandsonID/
and every parent can have a different number of children (some parents have 2 children, some have 3, some have 4 and some have 5 children).
How can I create more fields from the one that I have in order to get a number of fields equal to the numer of chidlren?
So, in my case I would like to have 5 different fields, one for each child.
Thanks a lot for your help and for your attention
Best regards
Nicolò Cogno
Then force one...
SubField(FieldName & '/', '/', 6) as Son4,
SubField(FieldName & '/', '/', 5) as Son3,
SubField(FieldName & '/', '/', 4) as Son2,
SubField(FieldName & '/', '/', 3) as Son1,
SubField(FieldName & '/', '/', 2) as Father
May be like this:
SubField(FieldName, '/', 1) as FielName1,
SubField(FieldName, '/', 2) as FielName2,
SubField(FieldName, '/', 3) as FielName3,
SubField(FieldName, '/', 4) as FielName4,
SubField(FieldName, '/', 5) as FielName5,
This works! Thanks a lot for your help
I'm sorry, but there's a little thing that is not working yet
My paths are written in this way
/parentID/childID/grandsonID/sonofthegrandsonID
and so I'm using
SubField(FieldName, '/', -1) as Son4,
SubField(FieldName, '/', -2) as Son3,
SubField(FieldName, '/', -3) as Son2,
SubField(FieldName, '/', -4) as Son1,
SubField(FieldName, '/', -5) as Father.
The problem is that in this way the paths with less than 5 elements are giving their elements to the fith field, than to the fourth field ecc and the fields that are at the beginning are left blank
How can I solve this? Should I do something like a conditional loading that takes into account the number of '/' that it finds in the string?
Thanks a lot again!!!!
How about if you do this
SubField(FieldName, '/', 6) as Son4,
SubField(FieldName, '/', 5) as Son3,
SubField(FieldName, '/', 4) as Son2,
SubField(FieldName, '/', 3) as Son1,
SubField(FieldName, '/', 2) as Father
I thought about it, but I don't have a '/' at the end of the path
Then force one...
SubField(FieldName & '/', '/', 6) as Son4,
SubField(FieldName & '/', '/', 5) as Son3,
SubField(FieldName & '/', '/', 4) as Son2,
SubField(FieldName & '/', '/', 3) as Son1,
SubField(FieldName & '/', '/', 2) as Father
Now everything works Thanks a lot for your time!!!