Skip to main content

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2023, a live, in-person thrill ride. Save $300 before February 6: REGISTER NOW!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

USING WHERE

hii I am again here with a very simple and stupid question.

I am trying to apply two condition on the data while loading, i used

where division= 10 or division=20

which is working fine but at the same time I have to put condition and where document_type is not equal to 'ABC' and 'DEF'

i tried doing

where division='10' or division='12' and Document_type <> 'ABC' or Document_type <> 'DEF'

will it work

thanks in advance

1 Solution

Accepted Solutions
bill_markham
Champion III
Champion III

Often clearer to use brackets as well and force the evaluation order correclt:

     where ( division='10' or division='12' ) and ( Document_type <> 'ABC' or Document_type <> 'DEF' )

Or maybe use the Match() function :

     where Match (division,'10',12') and not Match (Document_type ,'ABC' ,'DEF')

View solution in original post

6 Replies
Not applicable
Author

and can I use multiple Where statements in same script

if yes then how

Not applicable
Author

I am not aware of any reason why you cannot have multiple conditions/fields in your 'where'clause - you may want to use parenthesis to group correctly.

not sure I understand why you want to ahve multiple where clauses in a single select statement

eduardo_sommer
Partner - Specialist
Partner - Specialist

Use

Where (Division = '10' or Division = '12')

    and Document <> 'ABC'

    and Document <> 'DEF'

Eduardo

bill_markham
Champion III
Champion III

Often clearer to use brackets as well and force the evaluation order correclt:

     where ( division='10' or division='12' ) and ( Document_type <> 'ABC' or Document_type <> 'DEF' )

Or maybe use the Match() function :

     where Match (division,'10',12') and not Match (Document_type ,'ABC' ,'DEF')

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Be careful with multiple conditions and the relational operators you use to tie them together. The clause

where division='10' or division='12' and Document_type <> 'ABC' or Document_type <> 'DEF'


will not do what you intend to do, because the combination division='10' and Document_type = 'ABC' will still get loaded. The first and the last parts of your where clause will match...


To be absolutely sure that the correct parts are combined and evaluated in the right order, use parentheses to group conditions. For example, this clause will act according to your description. It isn't that different from your original:


where (( division='10' ) or ( division='12' )) and (Document_type <> 'ABC') AND (Document_type <> 'DEF')


An alternative would be to use the match() function. Makes things a bit easier. For example, the previous WHERE is equal to the following:


where Match(division, '10', '12') and Not Match(Document_type, 'ABC', 'DEF')


Best,


Peter

Not applicable
Author

I got that . Thank you very much.. I really appreciate it.