Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How could I get this color expression to work?

Hello all,

I appreciate all the help I've gotten on here so far and all that is to come. I am working on a map visualization, where I color code portions of the United States various colors to show ranks in regard to health care. I have already imported my data and a KML file to display the states. I'm attaching screenshots of the map and the expression that I thought would work (but doesn't). Any insight into what's wrong would be amazing and thanks again in advance!

Sincerely,snip1.PNG

Munna snip2.PNG

6 Replies
swuehl
MVP
MVP

Seems like you are missing all opening and closing parentheses with your if() functions.

if - script and chart function ‒ Qlik Sense

And the color functions should not be enclosed in single quotes.

Color functions ‒ Qlik Sense

Like

=If(Rank <10, Green(),

     If(Rank < 20, Yellow(), Red() )

)

Anonymous
Not applicable
Author

The expression syntax should be:

if(Rank<=10, springgreen(),

if(Rank>10 and Rank<=20, lightcyan(),

if(Rank>20 and Rank<=30, lightskyblue(),

if(Rank>30 and Rank<=40, lightsalmon(),

springgreen()

))))

(Notice Error in expression on the bottom of the screenshot)

Anonymous
Not applicable
Author

I tried updating it but I'm not sure what else is wrong. I added double quotes and parentheses around my if functions. Thanks for the help! snip3.PNG

Anonymous
Not applicable
Author

What could I do to get rid of that error in expression at the bottom? I am still getting it after pasting your function in the expression editor.

swuehl
MVP
MVP

The statement should logically look like

=If( Condition1, Then1, Else1)

or using nested statements:

=If(Condition1, Then1,                                    // Else1 is another if()

                    If(Condition2, Then2,                     // Else2 is another if()

                                   If(Condition3, Then3,Else3)    

                    )

)

No quoting of functions (and you don't need to quote the numbers, too).

Anonymous
Not applicable
Author

Because the colors you use, don't exists, except lightcyan() - at least in my version of Sense.

Try to use rgb() function instead.


Edit: here is the list of predefined colors:

Color functions ‒ Qlik Sense