Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
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?

1 Solution

Accepted Solutions
sunny_talwar

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
MVP
MVP

Try like this

if((decile  <= 4

     , green()

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

          ,blue()

          , red()

       )

)

sunny_talwar

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
MVP
MVP

Or  like this

Pick(decile

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

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

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

)

sunny_talwar

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
MVP
MVP

Sure, you are right!

sunny_talwar

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
MVP
MVP

Unless decile is not an integer ...

sunny_talwar

Right, that is true