Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

AND and OR statement together.

How can I make the below if statement  work?

if([Performance] = 9 OR IF([Performance] = 10 AND IF([Total # ] = 4 OR IF([Total # ] = 5,'0%',

  if([Performance] = 9 OR IF([Performance] = 10 AND IF([Total #] = 2 OR IF([Total # ] = 3,'0%',

   if([Performance] = 9 OR IF([Performance] = 10 AND IF([Total # ] = 0 OR IF([Total # ] = 1,'-3%',

  

   if([Performance] = 6 OR IF([Performance] = 7 OR [Performance] = 8 AND IF([Total # ] = 4 OR IF([Total # ] = 5,'0%',

    if([Performance] = 6 OR IF([Performance] = 7 OR [Performance] = 8 AND IF([Total # ] = 2 OR IF([Total # ] = 3,'0%',

      if([Performance] = 6 OR IF([Performance] = 7 OR [Performance] = 8 AND IF([Total # ] = 0 OR IF([Total # ] = 1,'-5%',

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

This is a literal correction of your expression:

If(([Performance] = 9 OR [Performance] = 10) AND ([Total # ] = 4 OR [Total # ] = 5), '0%',

  If(([Performance] = 9 OR [Performance] = 10) AND ([Total #] = 2 OR [Total # ] = 3), '0%',

   If(([Performance] = 9 OR [Performance] = 10) AND ([Total # ] = 0 OR [Total # ] = 1),'-3%',

   If(([Performance] = 6 OR [Performance] = 7 OR [Performance] = 😎 AND ([Total # ] = 4 OR [Total # ] = 5), '0%',

    If(([Performance] = 6 OR [Performance] = 7 OR [Performance] = 😎 AND ([Total # ] = 2 OR [Total # ] = 3), '0%',

      If(([Performance] = 6 OR [Performance] = 7 OR [Performance] = 😎 AND ([Total # ] = 0 OR [Total # ] = 1), '-5%'))))))

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

9 Replies
ajsjoshua
Specialist
Specialist

Hi,

Try <> for in place of OR

sunny_talwar

I have no idea what exactly are you trying to do. May be put this whole if statement in words and may be we can help?

Not applicable
Author

I guess this is not a qlikview expression. Don't try to converting the formula. First understand the requirement and in put data and write the expression on Qlikview way. I guess you don't need to many if here.

jonathandienst
Partner - Champion III
Partner - Champion III

This is a literal correction of your expression:

If(([Performance] = 9 OR [Performance] = 10) AND ([Total # ] = 4 OR [Total # ] = 5), '0%',

  If(([Performance] = 9 OR [Performance] = 10) AND ([Total #] = 2 OR [Total # ] = 3), '0%',

   If(([Performance] = 9 OR [Performance] = 10) AND ([Total # ] = 0 OR [Total # ] = 1),'-3%',

   If(([Performance] = 6 OR [Performance] = 7 OR [Performance] = 😎 AND ([Total # ] = 4 OR [Total # ] = 5), '0%',

    If(([Performance] = 6 OR [Performance] = 7 OR [Performance] = 😎 AND ([Total # ] = 2 OR [Total # ] = 3), '0%',

      If(([Performance] = 6 OR [Performance] = 7 OR [Performance] = 😎 AND ([Total # ] = 0 OR [Total # ] = 1), '-5%'))))))

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
jonathandienst
Partner - Champion III
Partner - Champion III

But that is very clumsy. The equivalent simplified expression would be

If(Match([Performance], 9 , 10) AND Match([Total # ], 0, 1), '-3%', 

  If(Match([Performance], 6, 7, 😎 AND Match([Total # ], 0, 1), '-5%',

  '0%'))

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Marcio_Campestrini
Specialist
Specialist

Hi Pavana

My guess is there's missing parenthesis in your expression. The only way to adjust is understanding the business rules

Márcio Rodrigo Campestrini
Not applicable
Author

Capture.GIF

above is the legend and based on that I have the if condition.I have this in the text box and also I have to have the rgb set.

Ex : if Score is 9 or 10 and Total# is 4 or 5 then 0%,rgb(green())

       if Score is 9 or 10 and Total# is 2 or 3 then 0%,rgb(green())

       if Score is 9 or 10 and Total# is 0 or 1 then -3%,rbg(yellow())

same thing for Score 6,7,8.

Thank you very much for your help.

Not applicable
Author

Thank you.

This is not working for me nor the other one.When I add the AND it doesnt work.

sunny_talwar

May be like this:

If(Match(Score, 9, 10),

     If(Match([Total#], 0, 1), '-3%', '0%'),

If(Match(Score, 6, 7, 8),

     If(Match([Total#], 0, 1), '-5%', '0%')))

If(Match(Score, 9, 10),

     If(Match([Total#], 0, 1), Yellow(), Green()),

If(Match(Score, 6, 7, 8),

     If(Match([Total#], 0, 1), Red(), Green())))