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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Nested IF condition

Hello All,

I am working on color coding of a report where depending on certain comparison, the background color of the report should change. The condition is something given below:

if (x=0)

{

if (a>b)

{red color};

else if (a<b)

{green color}

else

{amber color}

}

else if(x=1)

{

if(a<b)

{green color}

else if(a>b)

{red color}

else

{amber color}

}

else if(x=2)

{ if ((a>b) and (c>d))

{red color}

else if ((a<b) and (c<d))

{green color}

else if ((a<b) or (c<d))

{amber color}

else

{blue color}

}

else

{blue color}

Can somebody please tell me how to implement this nested condition. I have tried the below option but it is not working. The loop never goes to default condition.

IF(vCal_Thresh = 0,

       IF(v_checkSales = 1, $(vRed),

       IF(v_checkSales = 0, $(vGreen)

       , $(vCal_Default_Color)

       ))

, IF(vCal_Thresh = 1,

       IF(v_checkGM = 1, $(vRed),

       IF(v_checkGM = 0, $(vGreen)

       , $(vDefault_Color)

       ))

,

IF(vCal_Thresh = 2,

       IF(v_checkSales = 1 and v_checkGM = 1, $(vRed),

       IF(v_checkSales = 0 and v_checkGM = 0, $(vGreen)

      , $(vDefault_Color)

       ))

     ,

IF(vCal_Default = 1

      , $(vDefault_Color)

       )

     

)))

2 Replies
tyagishaila
Specialist
Specialist

I think Pick Match functions can resolve your problem.

sunny_talwar

It would be difficult to troubleshoot without looking at a sample. Do you have a sample you can share with the expected output where each of the conditions can be tested out?