Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

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

Re: AND and OR statement together.

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
Valued Contributor

Re: AND and OR statement together.

Hi,

Try <> for in place of OR

Re: AND and OR statement together.

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

Re: AND and OR statement together.

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.

MVP
MVP

Re: AND and OR statement together.

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

MVP
MVP

Re: AND and OR statement together.

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
Valued Contributor

Re: AND and OR statement together.

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

Re: AND and OR statement together.

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

Re: AND and OR statement together.

Thank you.

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

Re: AND and OR statement together.

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