Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Nested if for color expression

Howdy, I am trying to make a conditional if statement for a color expression in qlik sense. It goes something like this:

if((decile = '1' or decile = '2' or decile = '3' or decile = '4'), green(),

if (decile = '5' or decile '6' or decile = '7')

,blue()

if(decile = '8' or decile = '9' or decile = '10')

,red())

but for some reason I am still getting an error on parenthesis, 'expecting a ')'. Any assistance?

Labels (1)
1 Solution

Accepted Solutions
sunny_talwar
MVP
MVP

Another one would be:

If(Match(decile, 1, 2, 3, 4), Green(),

If(Match(decile, 5, 6, 7), Blue(),

If(Match(decile, 8, 9, 10), Red())))

View solution in original post

12 Replies
ecolomer
Master II
Master II

in the tirdh row ypou need a "," at end of blue()

if((decile = '1' or decile = '2' or decile = '3' or decile = '4'), green(),

if (decile = '5' or decile '6' or decile = '7')

,blue(),

if(decile = '8' or decile = '9' or decile = '10')

,red())

and you need add two ) at the end

See:

if ((decile = '1' or decile = '2' or decile = '3' or decile = '4'), green(),

if ((decile = '5' or decile '6' or decile = '7'), blue(),

if ((decile = '8' or decile = '9' or decile = '10'), red())))

swuehl
Champion III
Champion III

Try like this

if((decile  <= 4

     , green()

     , if (decile >= 5 and decile <=7

          ,blue()

          , red()

       )

)

sunny_talwar
MVP
MVP

Another one would be:

If(Match(decile, 1, 2, 3, 4), Green(),

If(Match(decile, 5, 6, 7), Blue(),

If(Match(decile, 8, 9, 10), Red())))

swuehl
Champion III
Champion III

Or  like this

Pick(decile

, green(),green(),green(),green()

,blue(),blue(),blue()

,red(),red(),red()

)

sunny_talwar
MVP
MVP

Stefan do you think we can go away with  >= 5 from your proposal? Like the below

If(decile  <= 4, green(),

If(decile <= 7, blue(), red()))

swuehl
Champion III
Champion III

Sure, you are right!

sunny_talwar
MVP
MVP

A lot of time people has asked me if the above as true as what you have proposed and I have always wondered if there is a time when they won't give the same result. I guess never

swuehl
Champion III
Champion III

Unless decile is not an integer ...

sunny_talwar
MVP
MVP

Right, that is true