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

Announcements
Learn how to migrate to Qlik Cloud Analytics™: On-Demand Briefing!
cancel
Showing results for 
Search instead for 
Did you mean: 
wizardo
Creator III
Creator III

can an IF statement with an OR operand be converted to set anaysis?

hi again,

lets say i have this exrpesion

sum( if(STATUS1='open' OR STATUS2='open',sales)

is there a way to convert it into set analysis?

basicly what i need is a way to make an OR selection between values in two fields.

is this posible?

come to think of it i don't really know how to do it with normal selections.

i mean with clicking on values in the layout.

any suggestions?

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

Set analysis includes operators for union (+), intersection (*), exclusion (-) and XOR (/). So I think you'd write it like this:

sum({<STATUS1={open}>+<STATUS2={open}>}sales)

But I could easily have the syntax wrong, as I didn't see any good examples in the help text. A little experimentation should get you there.

View solution in original post

7 Replies
johnw
Champion III
Champion III

Set analysis includes operators for union (+), intersection (*), exclusion (-) and XOR (/). So I think you'd write it like this:

sum({<STATUS1={open}>+<STATUS2={open}>}sales)

But I could easily have the syntax wrong, as I didn't see any good examples in the help text. A little experimentation should get you there.

wizardo
Creator III
Creator III
Author

hi there John

in the help it sais:

"All set operators use sets as operands"

in your example you are using modifiers(<>) as operands

is that allowed?

johnw
Champion III
Champion III

I'm not using modifiers as operands. I'm using sets as operands. The first set is <STATUS1={open}>. The second set is <STATUS2={open}>. Works fine. See attached.

Not applicable

Sum( {$<status1={open}>} Value) + Sum( {$<status2={open}>} Value)

johnw
Champion III
Champion III


carneyfm wrote:
Sum( {tiny_mce_markerlt;status1={open}>} Value) + Sum( {tiny_mce_markerlt;status2={open}>} Value) <div></div>


Not if the two sets intersect. For a very simple example, say there's only one record, both status1 and status2 are open, and the Value is 1. Your expression will return 2. It should return 1.

wizardo
Creator III
Creator III
Author

hmm i can see its working allright but...

i thought if its enclosed in <> then its a modifier

from the help:

"The modifier consists of one or several field names, each followed by a selection that should be made on the field, all enclosed by < and >"

johnw
Champion III
Champion III

Hmmm, I agree with you - it sounds like the help text is saying that I'm doing a union on two modifiers, not on two sets. And that doesn't sound like something that would work. Since it DOES work, I'd just chalk it up to poorly-written help text. I do certainly feel that the set analysis help could be more clear, and more importantly, could include a lot more examples.