Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

scheibercamo
New Contributor II

How do I color bars in a bar chart by expression (number range)?

Hi -

I am trying to color the below bars by expression, trying to go off a set analysis:


IF(COUNT({< Date=, [Status]={'Value 1'}>}[Tag_ID])>= 20, vRed,vGreen) WHERE vRed and vGreen are color variables.


For some reason, this set analysis isn't working even though I wrote this expression under "Background Color" for the chart. Ideally, what I would like to see is two Red bars (since these numbers are above 50) and a green third bar. Right now they are all red and this is not right.


Any advice on this? The expression behind the bar chart itself is:


=COUNT({<Date=,[Status={'Value 1'}>}[Tag_ID])


Thanks for your help in advance!


Ricky

1 Solution

Accepted Solutions

Re: How do I color bars in a bar chart by expression (number range)?

Since this was a mockup, I used this expression

=If(Sum(Tag_ID) >= 20, RGB(255,79,77), RGB(0,198,64))

Where my chart's expression is

=Sum(Tag_ID)

13 Replies

Re: How do I color bars in a bar chart by expression (number range)?

May be try this?

If(Count({<Date, [Status] = {'Value 1'}>} [Tag_ID]) >= 20, $(vRed), $(vGreen))

scheibercamo
New Contributor II

Re: How do I color bars in a bar chart by expression (number range)?

Just tried - didn't work By the way - the only reason I included the "Date=" in the color expression is because I have that in my original expression. I tried removing it from your solution and it still didn't work.

Do I need to include that part of the set analysis?

Re: How do I color bars in a bar chart by expression (number range)?

Can you show how exactly do you define vRed and vGreen?

scheibercamo
New Contributor II

Re: How do I color bars in a bar chart by expression (number range)?

vRed = RGB(255,79,77)

vGreen = RGB(0,198,64)

Re: How do I color bars in a bar chart by expression (number range)?

Just out of curiosity, does this work?

If(Count({<Date, [Status] = {'Value 1'}>} [Tag_ID]) >= 20, RGB(255,79,77), RGB(0,198,64))

scheibercamo
New Contributor II

Re: How do I color bars in a bar chart by expression (number range)?

No Perhaps you can share an example of bars within a chart colored by expression that I could use as a baseline? 

Re: How do I color bars in a bar chart by expression (number range)?

Here is a very simple mock up for you

Capture.PNG

scheibercamo
New Contributor II

Re: How do I color bars in a bar chart by expression (number range)?

Do you have the expression behind this chart? For the general one and the background color. Thanks!

I'm working in Qlikview by the way.

Re: How do I color bars in a bar chart by expression (number range)?

You opened your thread in Qlik Sense forum that is what confused me... here is a QlikView sample and image

Capture.PNG

Community Browser