3 Replies Latest reply: Jul 8, 2016 4:59 AM by bruno bertels

# Color by Variable

Hi

I have a colour problem in a bar chart. The bar chart is composed by 3 different measures that are the result of a difference between specific percentage from 2 different tables (ANAG and LOG).

If I chose "Automatic Colour" or "Multicolour" the 3 different variables will have 3 different colour (like in the picture).

I need that this 3 colours (blue, yellow and rose) arent based on the default colour, but I have to choose it

The variable \$(scostamentoRichM) is composed with this expression :

```//\$(scostamentoRichM):
(sum({<[Sesso]= {'Maschio'}>} rich_totali)  /  (Sum(rich_totali))  *100)   //this percentage is from table LOG
-
(sum({<[Usp_a_SESSO]= {'M'}>} Usp_a_NUM)  //this percentage is from table ANAG
/
(sum({<[Usp_a_SESSO]= {'M'}>} Usp_a_NUM)
+sum({<[Usp_a_SESSO]= {'F'}>} Usp_a_NUM)
+sum({<[Usp_a_SESSO]= {'ND'}>} Usp_a_NUM)) *100)
```

The other 2 variables have the same espression but is called \$(scostamentoRichF) and \$(scostamentoRichND).

I need the coloration  like this (picture below):

\$(scostamentoRichM)  = rgb(130,51,0)

\$(scostamentoRichND)  = rgb(240,220,130)

\$(scostamentoRichF)  = rgb(219,112, 32)

THANKS!!

• ###### Re: Color by Variable

Hi

See this post it may help

https://community.qlik.com/message/1074046#1074046

and this one also for bar chart

https://community.qlik.com/docs/DOC-8492

the principe is to

ValueList('mesure1','mesure2','mesure3')

if(ValueList('mesure1','mesure2','mesure3')='mesure1'

,\$(scostamentoRichM)

,if(ValueList('mesure1','mesure2','mesure3')='mesure2'

,\$(scostamentoRichND)

,\$(scostamentoRichF)

)

)

and now set the color like this

if(ValueList('mesure1','mesure2','mesure3')='mesure1'

,rgb(130,51,0)

,if(ValueList('mesure1','mesure2','mesure3')='mesure2'

,rgb(240,220,130)

,rgb(219,112, 32)

)

)

Hope it helps

• ###### Re: Color by Variable

Thanks. It Works!!