Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Combination of AND and OR function in Set Analysis.

I have a sql query as given below :-

Sum(Amount) from table where A=1 AND B=1 AND C=1 AND(X=NA OR Y=NA OR Z=NA)

How can I write this sql query in my SET Analysis expression?

1 Solution

Accepted Solutions
maxgro
MVP
MVP

try

sum({$ <A={1},B={1},C={1}>*(<X={NA}>+<Y={NA}>+<Z={NA}>)}  Amount)

View solution in original post

4 Replies
Not applicable
Author

Hi Anees,

I would suggest creating a flag in your script and then using this in your set analysis.

Load *,

If(A=1 AND B=1 AND C=1 AND(X='NA' OR Y='NA' OR Z='NA'),1) as %Flag

from....

Sum({<%Flag={1}>} Amount)

Hope that helps

Joe

Digvijay_Singh

Se if this can be used, will be simpler if can be used in your situaiton-

=Sum(if(A=1 and B=1 and C=1 and (X='NA' or Y='NA' or Z='NA'),Amount))

maxgro
MVP
MVP

try

sum({$ <A={1},B={1},C={1}>*(<X={NA}>+<Y={NA}>+<Z={NA}>)}  Amount)

Not applicable
Author

Thanks a bunch max 🙂

Now it is working as per our requirement.