12 Replies Latest reply: May 28, 2015 4:42 AM by Clare Sim

# Bar Chart conditional color formatting

Hi,

I am trying to build a bar chart where the color will depend of a creteria that goes: if the sum > 40 then 'green' else 'red'. The color area is calculated with the following: "if( Sum (Sales) > 40, green(),red())". It looks like it colors all the bar with the sum condition representing the total on the chart, not the individual bars. What am I missing? In the attached qvw, bars are green when no selection is done, red when for example 'Germany' selected and also red when both 'Germany' and 'Switzerland' selected. If you add 'France', it all turns to green.

Thanks!

• ###### Bar Chart conditional color formatting

Hi Patrick

Find the attachment you will get your solution.

thanks

Zaman

• ###### Bar Chart conditional color formatting

Hi Patrick,

Whatever you have done is fine. when no selections are made, the chart shows you the total sum of sales value and it is above 40. That is why it is green in color. But when you select one by one, then it is showing red color representing that the values are less than 40. So as it is the graph is well and fine.

Thanks Joseph......

• ###### Bar Chart conditional color formatting

I hope the following set analysis may be helpful for you.

sum( {1} Sales )
returns total sales within the application, disregarding the selection but not the dimension. If used in a chart with e.g. Products as dimension, each product will get a different value.

sum( {1} Total Sales )
returns total sales within the application, disregarding both selection and dimension. I.e. the same as sum(All Sales).

• ###### Bar Chart conditional color formatting

Sounds like yo have put the color expression in the wrong place, it should be put in the Background Color subexpression on the expressions page.

• ###### Bar Chart conditional color formatting

Hi there, I have the same issue, this time with using minichart representations of values given a certain dimension (time, for example). Is it not possible to conditionally colour each bar based on its given value? Using Background colour of the measure expression does not work in this case, because there are many bars (one per month), not just the one. Using the colour expression within the minichart properties does not work because it aggregates the expression (does not take into account the dimension of the minichart) and applies the same colour based on the total to all the bars.

Thanks

Das

• ###### Re: Bar Chart conditional color formatting

Hi,

You need to give formula on "Background color" in Exprssion.

See the attachment.

Lumen

• ###### Bar Chart conditional color formatting

Hi, I'm new in Qlik View, where is "Backround color" in Expression ???

Thanks

• ###### Re: Bar Chart conditional color formatting

Regards

Lumen

• ###### Bar Chart conditional color formatting

Thank you very much!!!

• ###### Re: Bar Chart conditional color formatting

But, if I have done a chart with percentage like this one:

I have try to insert different colours with this espression: if((count(%ticketid)/count(total %ticketid))*100<80, \$(az), \$(bl)). . . but it doesn't work well.

where \$(az) and \$(bl) are 2 colours.

• ###### Re: Bar Chart conditional color formatting

Hi!

Did you get an answer?

I'm trying to create a chart - ticket 1 is supposed to be red, it should show red, and if ticket 2 is green, it should be green. my current condition doesn't seem to work. It's giving me an overall color view.. which is not right