26 Replies Latest reply: Jun 17, 2015 2:15 AM by Phaneendra Kunche

# Conditional Coloring

Hi guys,

I've been trying to do some searching for conditional expressions, but I haven't had any luck so far.

Right now I have two KPIs. One that shows Revenue from 2014 and one from 2015.

I did set analysis to filter the revenue by the year:

2014 Revenue Expression: Sum({\$<Year={"FY14"}>}"Revenue")

2015 Revenue Expression: Sum({\$<Year={"FY15"}>}"Revenue")

Now, I would like the 2015 Revenue to be a certain color depending on if it's higher or lower than 2014 Revenue (example: red if lower, green if higher).

I checked conditional coloring, but I'm a little confused as to how the expression should be formatted (most likely an if expression?).

Any help would be greatly appreciated. Thanks!

• ###### Re: Conditional Coloring

if ( Sum({\$<Year={"FY15"}>}"Revenue")- Sum({\$<Year={"FY14"}>}"Revenue")<0,red(),green())

You can set these in the the background/text color options for the expression by clicking on the +sign in front of the expression.

• ###### Re: Conditional Coloring

Where exactly do I put the expression you wrote?

In the min/max ranges for conditional coloring? That doesn't seem to work.

Thanks for your quick response.

• ###### Re: Conditional Coloring

So where you use these expressions?? In a chart bar/table/pivot/text box??

I was assuming in a chart, in the expression tab click on the plus sign

• ###### Re: Conditional Coloring

Oh sorry, I see now this is for Sense, not sure this applies. Sorry

• ###### Re: Conditional Coloring

Yes, I'm using Qlik Sense. Thanks for your help though!

If anyone else knows how to correctly apply conditional coloring in this case, I would greatly appreciate it!

• ###### Re: Conditional Coloring

Which object are you using?

KPI object, Table, Bar, Line?

• ###### Re: Conditional Coloring

I'm using KPI!

• ###### Re: Conditional Coloring

Assuming you have tow KPI objects one with 2014 and one with 2015.

see attached for the reference. Choose "A2Z Solutions" as customer in the filter.

At a glance what i did is...

1. enable conditional colors for the metric you need to color.

2. add a limit

3. in Min box input 2014 expression

4. in Max box input 2015 expression

5. for lower bound pick green and upper bound pick red.

• ###### Re: Conditional Coloring

I understand the way you organized it, but what if 2015 is lower than 2014? Then it wouldn't work as a max. Wouldn't we need an if statement or the like?

• ###### Re: Conditional Coloring

You don't need that to define. coz that will be taken care by upper bound Red color. Assuming that you are trying to color only 2015 KPI object.

• ###### Re: Conditional Coloring

Where do you put the sliding bar below the red/green? It seems like yours doesn't even move...? But the segments are still defined by it.

• ###### Re: Conditional Coloring

I still don't understand how 2015 Revenue can serve as a "max" if it is actually lower than 2014 Revenue? I just tried it, and the conditional coloring did not work.

• ###### Re: Conditional Coloring

Can you post your QVF if possible?

• ###### Re: Conditional Coloring

I can't insert the qvf due to sensitive data, but here is a screenshot. I have followed your steps for Min/Max. For the slider, I tried putting the 2014 sales data, but that didn't seem to work (such as when I made 2015 smaller than 2014).

• ###### Re: Conditional Coloring

I see 2015 value being higher and will show in GREEN. if it lower than 2014 then it should show RED. am i missing something here.

you have 59.83M for 2014 which is lower than 62.76M for 2015. So 2015 will be Green. or else it will be red.

• ###### Re: Conditional Coloring

Look at the circled part of the screenshot. The red/green will actually depend on that number. Not compared to 2014/2015.

I tried making that circled value as 2014's value. But it did not work.

Additionally, I tried making 2015 lower than 2014 and it did not change to red.

• ###### Re: Conditional Coloring

Here is another screenshot if I simply just change the data for 2015 to make it smaller. For some reason the color did not change. I did not make any changes to Qlik.

• ###### Re: Conditional Coloring

So you added as mentioned below correct?

• ###### Re: Conditional Coloring

Yes I did everything you said. When 2015 is higher than 2014, it works fine. The problem is that when 2015 is lower than 2014, it does not work (color doesn't change correctly).

Edit: Additionally, sometimes I am able to adjust it so the colors change correctly, but the glyphs do not. Seems kind of strange since the glyph should be associated with the colors?

• ###### Re: Conditional Coloring

Hmmm...What version are you on? are you on version 1.1? or 1.0.x?

• ###### Re: Conditional Coloring

I'm on 1.1

• ###### Re: Conditional Coloring

Thats odd. im on 1.1 too. So when you opened up my attached example is it working?

When you select "A2Z solutions" you should see GREEN

and when you select "Active Data" you should see RED.

It should have been nice if we have option like Color by expression that we have in Table. May be they will come up with next versions 2.0 and later.

• ###### Re: Conditional Coloring

That's a good point actually.

On your file, yes the colors work. I managed to get the colors to work on mine too.

On your file, can you try adding a ^ to the green and a v to the red? (glyphs)

They do not seem to work or update correctly.

• ###### Re: Conditional Coloring

glyphs are not working. It always picks one and doesnt show conditionally.

May be can use like the one in attached.

• ###### Re: Conditional Coloring

Hmm, do you know why the glyphs are behaving that way? Seems so strange. I would love to be able to get it to work properly.

Thanks for all your help so far!

• ###### Re: Conditional Coloring

Not sure why. May be it is a bug. As i said earlier it will be great if qlik can add conditional coloring in later releases.

Please mark the appropriate replies as CORRECT / HELPFUL so our team and other members know that your question(s) has been answered to your satisfaction.

Thanks,

Phani