Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

ts3st1000
New Contributor

Color Bar Chart

Hi, I have a bar chart displaying two variables, Foreign Sales and Domestic Sales that I draw one next to the other per product.

I am trying to have each one in different color and i tried the following under Colors and legend, Colors custom, By expression:

if('Foreign Sales', red() ,if('Domestic Sales', green()))

But the above did not work. Any suggestion how to fix this code please?

Thanks very much.

13 Replies
omarbensalem
Esteemed Contributor

Re: Color Bar Chart

by variables; you mean measures? u have 2 measures?

madhur4qlik
New Contributor III

Re: Color Bar Chart

you can use RGB() fucntion with IF clause. mention rgb values from any color format window.

e.g If(Sales>10, RGB(245,24,18), rgb(45,7,9)

use this in TeXT Color under the your expression

arvind654
Honored Contributor II

Re: Color Bar Chart

if(getselectedcount(Foreign Sales)=1,Green(),red())

Above would give red color if Foreign Sales is selected or with no selection it would stay red color.

This will work only upon SELECTION in field.

It would be helpful if you tell us if it is a variable or measure or dimension?


ts3st1000
New Contributor

Re: Color Bar Chart

Yes both Foreign Sales and Domestic Sales are measures. thanks for the help.

omarbensalem
Esteemed Contributor

Re: Color Bar Chart

What version of Qlik Sense are u using? (please answer rapidly, I'm not staying long..)

ts3st1000
New Contributor

Re: Color Bar Chart

Qlik Sense 3.2 SF5

omarbensalem
Esteemed Contributor

Re: Color Bar Chart

Well if It's june, september, or november 2017 (maybe even 3.2..., I've forgotten..);

Create ur 2 measures as master measures:

Capture.PNG

when u use these new master measures; u'll find them colored as u want:

Capture.PNG

Capture.PNG

omarbensalem
Esteemed Contributor

Re: Color Bar Chart

And please think about upgrading to the last version (Qlik Sense November 2017)

ts3st1000
New Contributor

Re: Color Bar Chart

Thanks Madhur. but i dont have any other condition on my two variables (foreign sales and domestic sales) other than i want them in two different colors. No such condition as sales >10.

ubt

I have tried this If(Sales, RGB(245,24,18), rgb(45,7,9))  but it did not work.