Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Not applicable

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).

ok.PNG

I need the coloration  like this (picture below):

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

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

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

ok2.png

THANKS!!

1 Solution

Accepted Solutions
brunobertels
Valued Contributor

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

Set your dimension normally

Add second dimension like this

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


then add mesure

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

3 Replies
brunobertels
Valued Contributor

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

Set your dimension normally

Add second dimension like this

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


then add mesure

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

Not applicable

Re: Color by Variable

Thanks. It Works!!

brunobertels
Valued Contributor

Re: Color by Variable

glad to hear that