Qlik Community

Qlik Sense Enterprise Documents & Videos

Documents & videos about Qlik Sense.

Qlik Sense - Making each level of a drill-down dimension a different colour in a treemap

stephanies
New Contributor III

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 drill-down dimension = 'Dogs Drilldown'

Comprising = Level 1: 'Type'  >drills to> Level 2: 'Breed' >drills to> Level 3: 'Colouring'

Colours: Type = rgb(185,19,114) pink, Breed = rgb(114,185,19) green, Colouring = rgb(19,114,185) blue

On the treemap option sidebar, select 'Appearance'/'Colors and Legend', toggle to 'Custom' and pick 'By expression'.

Code: 

IF(wildmatch(GetCurrentSelections('Dogs Drilldown'),'*Breed*'),
    rgb(19,114,185),
    IF(wildmatch(GetCurrentSelections('Dogs Drilldown'),'*Type*'),
    rgb(114,185,19),
    rgb(185,19,114))
     )

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!

Dogs Drill L1.PNGLevel 1 -Type. Topmost level. No drill-down yet.Dogs Drill L2.PNGLevel 2 - Breed. 'Hound' category selected from Level 1.Dogs Drill L3.PNGLevel 3 - Colouring. Deepest level. 'Greyhound' category selected. Cannot drill further.

 

Version history
Revision #:
1 of 1
Last update:
‎2019-01-11 12:14 PM
Updated by:
 
Contributors