# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
Not applicable

## Color treemap by Expression

Hello Qlik Community,

I am using a treemap on QlikSense with two dimensions and one measure. I wanted to know if it was possible to color each rectangle of the treemap based on the measure.

Let's suppose that my first dimension is Country and my second dimension is City (please note that the dataset is only composed of 3 countries otherwise the treemap would become unmanageable). My measure is the sum of goods sold in each city.

So i would like to know if it was possible (if so, how?) to color each city based on the sum of goods sold?

For France, if the sum of goods sold in Paris is higher than 10 then color the rectangle for Paris in GREEN otherwise in RED

if the sum of goods sold in Lyon is higher than 20 then color the rectangle for Lyon in GREEN otherwise in RED

if the sum of goods sold in Toulouse is higher than 30 then color the rectangle for Toulouse in GREEN otherwise in RED

For Italy ,   if the sum of goods sold in Milan is higher than 65 then color the rectangle for Milan in GREEN otherwise in RED

if the sum of goods sold in Naples is higher than 50 then color the rectangle for Naples in GREEN otherwise in RED

if the sum of goods sold in Rome is higher than 25 then color the rectangle for Rome in GREEN otherwise in RED

.

For Germany, if the sum of goods sold in Berlin is higher than 10 then color the rectangle for Berlin in GREEN otherwise in RED

if the sum of goods sold in Dortmund is higher than 50 then color the rectangle for Dortmund in GREEN otherwise in RED

I have tried to do a nested if as shown below, unifortunately it only worked for Paris and Lyon and not for the rest:

 if( city='Paris' and Sum(Sales)>10,rgb(24,212,137),
 if( city='Paris' and Sum(Sales)<10,rgb(165,25,36),
 if( city='Lyon' and Sum(Sales)>20,rgb(24,212,137),
 if( city='Lyon' and Sum(Sales)<10,rgb(165,25,36),
 if( city='Toulouse' and Sum(Sales)>20,rgb(24,212,137),
 if( city='Toulouse' and Sum(Sales)<10,rgb(165,25,36),
 if( city='Milan' and Sum(Sales)>65,rgb(24,212,137),
 if( city='Milan' and Sum(Sales)<65,rgb(165,25,36),
 if( city='Naples' and Sum(Sales)>50,rgb(24,212,137),
 if( city='Naples' and Sum(Sales)<50,rgb(165,25,36),
 if( city='Rome' and Sum(Sales)>25,rgb(24,212,137),
 if( city='Rome' and Sum(Sales)<25,rgb(165,25,36),
 if( city='Berlin' and Sum(Sales)>10,rgb(24,212,137)
 if( city='Berlin' and Sum(Sales)<10,rgb(165,25,36),
 if( city='Dortmund' and Sum(Sales)>50,rgb(24,212,137),
 if( city='Dortmund' and Sum(Sales)<50,rgb(165,25,36)))))))))))))))))

Please if you have any idea or suggestions, it will be highly appreciated.

Thanks.

2 Replies
Not applicable

## Re: Color treemap by Expression

Try reducing the complexity of your expression by only checking for the red conditions then at the end if none are met then set to green rather than define each case.  Might make it easier to trouble shoot.

Not applicable

## Re: Color treemap by Expression

thanks for the suggestion, will definitely look into it.

Community Browser