Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Set Analysis Operators and or or or or whaaat?

Hi nice people,

I have a question regarding set analysis with operators.

I figured out how to use AND & OR Operators... here my simplified solution:

AND (show customer with customerID 1234 that bought Product A):

=SUM({< [CustomerID] = {'1234'}> * < [Product] = {'A'}> }[Values])

OR (show everything that is Product A or Product B:

=SUM({< [Product] = {'A'}> + < [Product] = {'B'}> }[Values])

HOWEVER, when I combine them to select Customer with ID 1234 that bought Product A or Product B something doesn't work out 😉 - what did I do wrong

??? =SUM({< [CustomerID] = {'1234'}> * < [Product] = {'A'}> + < [Product] = {'B'}>}[Values])  ???

 

Can you please help me 🙂 thx

all the best

george

Labels (2)
1 Solution

Accepted Solutions
marcus_sommer

If you want to combine multiple AND's and OR's you need to use appropriate brackets. And this is within a set analysis not different to any other expression, usually applied within if-loops, like:

SUM({< [CustomerID] = {'1234'}> * (< [Product] = {'A'}> + < [Product] = {'B'}>)}[Values])

Whereby if I understand your target right it could be done easier respectively more "classical" in regard to the common used syntax, like:

SUM({< [CustomerID] = {'1234'}, [Product] = {'A','B'}>}[Values])

- Marcus

View solution in original post

2 Replies
marcus_sommer

If you want to combine multiple AND's and OR's you need to use appropriate brackets. And this is within a set analysis not different to any other expression, usually applied within if-loops, like:

SUM({< [CustomerID] = {'1234'}> * (< [Product] = {'A'}> + < [Product] = {'B'}>)}[Values])

Whereby if I understand your target right it could be done easier respectively more "classical" in regard to the common used syntax, like:

SUM({< [CustomerID] = {'1234'}, [Product] = {'A','B'}>}[Values])

- Marcus

Anonymous
Not applicable
Author

Legend! thank you so much!!!