Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
ts3st1000
Contributor
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

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

madhur4qlik
Partner - Contributor III
Partner - Contributor III

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

MK9885
Master II
Master II

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
Contributor
Contributor
Author

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

OmarBenSalem

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

ts3st1000
Contributor
Contributor
Author

Qlik Sense 3.2 SF5

OmarBenSalem

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

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

ts3st1000
Contributor
Contributor
Author

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.