Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

Conditional Coloring and Divided Legend

I am having trouble conditionally formatting the colors within my chart to display red for values below zero and green for values above zero. My questions are as follows:

1) My colors are displaying based on my conditional statement, however, I like the style 'Light Gradient.' However, I wish the green would display as the other colors, in a solid manner.

     ssss.png

Example Chart

2) I would also like a split legend icon that represent two potential values for a single expression. For example, profit margin. If margins are below zero, it should be colored rgb(255,0,0), else rgb(0,255,0). 

split icon.png

Example Split Legend Icon

Thanks in advance to any and all help!

1 Solution

Accepted Solutions
stigchel
Honored Contributor

Re: Conditional Coloring and Divided Legend

You can use the background color option of the expression (click on the plus sign in front of the expression) and use something like

if(MyExp<0,red(),green())

Where MyExp is the label of your expression (put between [] brackets if there are spaces)

LineGreenRed.png

6 Replies
stigchel
Honored Contributor

Re: Conditional Coloring and Divided Legend

Hi Michael,

1) Change the color in the color tab(You can not make/use gradient colors in expressions) or include it in your conditions  to display a solid color.

2) that's not natively possible, but you create your own custom legend, see e.g.

Listbox Color Chips | Qlikview Cookbook

stigchel
Honored Contributor

Re: Conditional Coloring and Divided Legend

Hi Michael,

My previous post is in moderation, probably because I referred to an external link. This is an alternative link from the community, as this moderation may take some time

1) Change the color in the color tab(You can not make/use gradient colors in expressions) or include it in your conditions  to display a solid color.

2) that's not natively possible, but you create your own custom legend, see e.g.

Use of a Silent Legend

Not applicable

Re: Conditional Coloring and Divided Legend

Thanks for the fast reply. What is the syntax to display a solid color?

stigchel
Honored Contributor

Re: Conditional Coloring and Divided Legend

You can use one of the following for e.g. red

=rgb(255,0,0)

=red()

=Color(1)

for the last one, 1 is an index referring to the colors in the color tab of the chart's properties, so only if color 1 is red

stigchel
Honored Contributor

Re: Conditional Coloring and Divided Legend

You can use the background color option of the expression (click on the plus sign in front of the expression) and use something like

if(MyExp<0,red(),green())

Where MyExp is the label of your expression (put between [] brackets if there are spaces)

LineGreenRed.png

Not applicable

Re: Conditional Coloring and Divided Legend

Thanks Piet!

Community Browser