If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.
The Qlik documentation provides an example on how to color both background and text using two if statements in the color by expression field:
Example: Coloring table object font and background by measure value.
if(Sum([Sales]) < 10000, 'red', green())
if(Sum([Sales]) > 200000, 'gold', )
In this example, two expressions are used to color the background and text of the Sales column. Measure values in Sales that are lower than $10000 have a red background color, all other values have a green background. In addition, the values that are higher than $200000 have the text color 'gold'.
Now, I cannot find a way to insert two IF statements inside a color by expression field. I have tried putting them in this way:
=if(num([3.7] + [11]) <5, 'red', green())
=if(num([3.7]+[11])>15, 'red')
but none of the two expressions has an effect (I don't get anything green nor red). If I remove the equal sign, I get "Error in expression, Garbage after expression: 'if'". So, how do I do that? What does the documentation mean exactly?
For clarity, what I want to do is to set both the background and label color for a map point layer.
Hi,
Simply by concatenating multiple IF statements:
If(/*your number*/ < 5,
Red(), //red if < 5
If(/*your number*/ > 15,
Green(), //green if > 15
Yellow() //yellow if >= 5 and <= 15
)
)
Thank you for your suggestion, but that code only changes the background color, not the label color.
The Qlik example is on a table object. There are two fields for the colors on a table object:
I don't know if it's possible to do the same with a map...
I see, then that must be the problem. Thank you.
Hi @FedericaQ ,
Did you check what result do you have when using num([3.7] + [11]) ? I mean before using it in a If statement i.e. result < 5
Regards,