Qlik Sense - Making each level of a drill-down dimension a different colour in a treemap
I wanted to show categories and their subcategories in a clear way, together with a count of the items within each category. I though creating a treemap using a drillable master dimension would be a clear way to display this information and provide a slick way of filtering through categories for the user.
However, I wanted each level of the drilldown to display in a different colour, so the categories were distinct. E.g. first level of categories pink, drill to the next set of subcategories and they're green, drill to the next and they're blue etc.
Not finding anything that worked in the Community, this is what I came up with (functioning in Qlik Sense Feb 2018, as at 11th Jan 2019):
The GetCurrentSelections code looks within the Dogs Drilldown master dimension at whatever levels I currently have selected, while the wildmatch with asterisk wildcards picks only the levels containing the keyword. There are three levels, so the code is essentially saying
"If I've drilled down by clicking on a Breed (level 2) to show the Colouring (level 3), colour the treemap blue. If I've drilled down by clicking on a Type (level 1) to show the Breed (level 2), colour the treemap green. If haven't done any drilling yet, colour the treemap pink."
The order of your IF statements should put the colour of the "deepest" level (the final level that doesn't let you drill further) first and the final THEN colour should be for the "topmost" level (where you haven't yet started to drill down).
Bit longwinded for such a small issue, but I hope this helps!