Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

markgraham123
Contributor II

Where statement in Scripting

Hello Everyone,

I'm trying to fetch the required records using where condition in the script.

Please lemme know whether the syntax i'm using is accurate or not.

Where Name='A' and (Zone='1' or Zone='2' or Zone='3' or Zone='9') and Name='B' and (Zone='12' or Zone='24' or Zone='37');


Please help.

1 Solution

Accepted Solutions

Re: Where statement in Scripting

That looks as if it will never return anything as Name will never equal 'A' and equal 'B'.

A complete guess here as to what your requirements are but this would probably return some rows :

Where

( Name='A' and (Zone='1' or Zone='2' or Zone='3' or Zone='9') )

  or

( Name='B' and (Zone='12' or Zone='24' or Zone='37') );

7 Replies

Re: Where statement in Scripting

That looks as if it will never return anything as Name will never equal 'A' and equal 'B'.

A complete guess here as to what your requirements are but this would probably return some rows :

Where

( Name='A' and (Zone='1' or Zone='2' or Zone='3' or Zone='9') )

  or

( Name='B' and (Zone='12' or Zone='24' or Zone='37') );

markgraham123
Contributor II

Re: Where statement in Scripting

Hi Bill,

There were many Zone values under Names A and B

I wanna return values only Zone = 1,2,3,9 from A

and

Zone = 12, 24, 37 from B.

Its working...Smiley Happy

Can i use the same logic for multiple parameters like Name C, D. ..etc..?

markgraham123
Contributor II

Re: Where statement in Scripting

Hi BIll,

Can i use Zone='1*' to fetch all the zonez starting with 1????

Re: Where statement in Scripting

It could look neater with the Match() function :

Where

( Name='A' and Match ( 'Zone'  ,'1' , '2' , 3' , '9') )

  or

( Name='B' and Match ( 'Zone'  , '2' , '24' , '37') ) ;



... and yup, you should be add same logic for your other Name values.



[Editted as I did a typo]

Re: Where statement in Scripting

Still another typo: no quotes around the field name... I won't tell anyone however

P.

Re: Where statement in Scripting

Use Wildmatch(Zone, '1*') instead of Match(Zone, '1') if you want to play with wildcards in Bill's example above. See QV Desktop help for more info.

markgraham123
Contributor II

Re: Where statement in Scripting

Hi Peter,

Thanq Verymuch.

Community Browser