Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

mbanerjee95
New Contributor

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

Tags (2)
6 Replies
MVP
MVP

Re: How could I get this color expression to work?

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() )

)

mov
Esteemed Contributor III

Re: How could I get this color expression to work?

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)

mbanerjee95
New Contributor

Re: How could I get this color expression to work?

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

mbanerjee95
New Contributor

Re: How could I get this color expression to work?

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.

MVP
MVP

Re: How could I get this color expression to work?

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).

mov
Esteemed Contributor III

Re: How could I get this color expression to work?

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

Community Browser