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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Inherit traits from parents in hierarchy?

Hi,

I'd like to know how I can have children inherit a parental trait in a hierarchy. If I had a hierarchy where only the parents had data for one field, I want some code to have children of that parent inherit that field value as well instead of having it come up as null. I'd attach an example but I was having trouble recreating it via an inline load - I got confused trying to load data that would translate to a hierarchy.

So for example, if a parent has the value "Brown" for a field [Hair Color] and the child has a null for [Hair Color], have a line of code that would translate in English to, "If the value for hair color is null, and the line item has a parent, grab the parent's hair color and use it as this line's hair color". If this works correctly this line's [Hair Color] will be "Brown".

Thanks,

Scott

1 Reply
pover
Partner - Master
Partner - Master

After making the hierarchy you could join the hierarchy table with the table that has the parent's characteristics. After joining the tables, evaluate the final final as you say,

if(isnull(child_hair_color),parent_hair_color,child_hair_color) as hair_color

You can also do a "mapping load...applymap" combination instead of a join.

Regards.