Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
nihhalmca
Specialist II
Specialist II

Bar Color in Combo Chart

Hi All,

I want to change single bar color in combo chart.

For Example: Dim = Product

Measure 1: Quantity

Measure 2: Price

Measure 3: Revenue

Note: Measure 1 & 2 are grouped (Drilling in Expression).

However My Requirement is, should display Quantity (Bar) is in Red color and Price (Bar) is in Green color. (When i click drill in chart)

Thank You.

Regards,

NiHhal.

1 Solution

Accepted Solutions
Clever_Anjos
Employee
Employee

Steve Dark, I think Nihhal L wants to see each bar with differente colors, right?

Maybe you don´t need an IF statement, a fixed lightred() and lightgreen() should work on each bar

View solution in original post

7 Replies
stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

If you drill on the expression you can enter code for the bar colour, it will need to be something like:

=if(Only(Product) = 'Quantity', rgb(255, 100, 100),

if(Only(Product) = 'Price', rgb(100, 255, 100),

if(Only(Product) = 'Revenue', rgb(100, 100, 255), null())))

Null will revert back to the colours on the colour tab of the chart.

I tend to always put colours in variables, so that the colour can be changed in one place regardless of where it appears, eg:

=if(Only(Product) = 'Quantity', $(vColQuantity),

if(Only(Product) = 'Price', $(vColPrice),

if(Only(Product) = 'Revenue', $(vColRevenue), null())))


Hope that helps,

Steve Dark

nihhalmca
Specialist II
Specialist II
Author

Thanks for swift reply,

Please let me know where can i paste exactly this script.

Actually i want to change color only for Quantity Bar.

NiHhal.

Clever_Anjos
Employee
Employee

Each expresion as an small "+" just beside it.

Click on it and set "Background Color"

Capturar.PNG.png

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Thanks Clever.

Nihal, if you follow Clever's screenshot you can find the Background Colour code.  The code will be:

=if(Only(Product) = 'Quantity', rgb(255, 100, 100),

if(Only(Product) = 'Price', null(),

if(Only(Product) = 'Revenue', null(), null())))


Obviously you could simplify to take out the IF statements for Price and Revenue - but this will allow you to drop in other colours at a later date if you wish.

Clever_Anjos
Employee
Employee

Steve Dark, I think Nihhal L wants to see each bar with differente colors, right?

Maybe you don´t need an IF statement, a fixed lightred() and lightgreen() should work on each bar

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Apologies, I missed that they were different expressions rather than dimensions.  In that case the simpler approach would be to go to the colours tab and click the multicoloured tick box and set colours 1, 2 and 3 through the UI.  Doing it in code perhaps the more robust though.

nihhalmca
Specialist II
Specialist II
Author

Thank You Clever Anjos.

NiHhal.