Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

ctheobald
New Contributor

Using an IF Statement with variables to change the Colour on a Map

Hi All,

First time user, so apologies if this question has been asked before, my google-fu is weak and I haven't been able to find an answer.

To begin, we are using QlikSense, I am not too sure on the version, I believe we are, at most, 1 version behind current.

Basically, I have used the below in the load statement of my app to define the colours used for RAG ratings within the app.

SET vGreenHex ='#46c646' ;

SET vAmberHex = '#ffcf02';

SET vRedHex = '#f93f17';

I also did the same for the score margins for Green and Red (I didn't bother with Amber as Amber is defined as being between Green's Minimum score, and Red's Maximum score which are the values specified).

SET vGreen = 92;

SET vRed = 85;

Historically we have been using an IF statement to define all this with hardcoded values. I want to change this so we can have a more "templated" approach to the new apps we role out.

This is the expression previously used: if(avg(AuditScore) > 85, '#46c646', if(avg(AuditScore) < 75, 'Tomato', 'Gold'))

I have changed this to the following: =if(avg(AuditScore) >= $(vGreen), $(vGreenHex), if(avg(AuditScore) <=$(vRed), $(vRedHex), $(vAmberHex)))

I have put this IF statement in the "Colors And Legend" section of a Map, the idea being we get a dot on a map for every audit, which is coloured based upon the result.

I have tried this in other charts, and got the same result.

Basically, it doesn't work. I have obviously done something wrong here, is anyone able to clarify this for me?

Thank you,

Chris

1 Reply
ctheobald
New Contributor

Re: Using an IF Statement with variables to change the Colour on a Map

Apologies, Resolved this myself seconds after hitting send.

=if(avg(AuditScore) >= $(vGreen), vGreenHex, if(avg(AuditScore) <=$(vRed), vRedHex, vAmberHex))

Works.

Basically, didn't need the $() around the Colour values.

Community Browser