Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Eddy
Contributor III
Contributor III

When to use operatos instead of list of fields in the modifier expression

Hello,

 

my question is regarding the difference of using set operators and just a comma separated list of fields in the set modifier expressions. 

Example: 

Here is my data set: 

Fruits:
Load * Inline [
Fruit, State, Amount
Apple, Foul, 2
Apple, Good, 8
Pear, Foul, 5
Pear, Good, 7
Banana, Foul, 4
Banana, Good, 5
];

 

I want to isolate the fruits with state "good", which are not bananas in my set expressions. 

1) Sum({1<State = {Good}>-1<Fruit={Banana}>}Amount)

This expression defines two sets, one of which modifies a set to isolate the "Good" fruits, the other one excludes the Bananas from this set. 

 

2) Sum({1<State = {Good},Fruit-={Banana}>}Amount)

This expression does the same, all bananas are isolated from the "good" fruits, I have the same result. 

 

So in which cases I would really need to use operators instead of just using the list of fields in the modifier expression like in 2? 

I attached this as qvf.

Best Regards, 

Eddy

 

Labels (3)
1 Solution

Accepted Solutions
sunny_talwar

Yup that def. is one of the use cases. Also, there might be other scenarios where you might need it.

View solution in original post

3 Replies
sunny_talwar

If you have worked with set theory you would know that there are usually multiple ways to calculate a given area within a venn diagram. Set analysis works the same way. You can get to the same result using few different methods. The only thing to worry with set analysis is that you have to make sure that you are getting the desired result based on different selections that you make. In your case, both your expressions seems to be giving the same result for with and without selections, so they seem equivalent. But if I have to comment about what is used more commonly, I would say options 2

Sum({1<State = {Good},Fruit-={Banana}>}Amount)

or even this

Sum({1<State = {Good},Fruit= e({1<Fruit = {Banana}>})>}Amount)

 

Eddy
Contributor III
Contributor III
Author

Thank you for your reply Sir, 

so I think the operators are needed for example when I want to add up a disjoint set, like all all "good" fruits (Good Apples, Pears, Bananas = 20) plus all bananas (which means adding up 4 "foul" bananas which are not included in the first set), like in the following expression:

Sum({1<State = {Good}>+<Fruit ={Banana}>}Amount)

and we get a count of 24.

 

sunny_talwar

Yup that def. is one of the use cases. Also, there might be other scenarios where you might need it.