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

Announcements
Save $650 on Qlik Connect, Dec 1 - 7, our lowest price of the year. Register with code CYBERWEEK: Register
cancel
Showing results for 
Search instead for 
Did you mean: 
surajap123
Creator III
Creator III

Diff between the 2 expressions

Hi All,

I thought both the below statements are same, so i created the 2nd one using set analysis. But i am getting different outputs

(Sum(IF(Status = 'Cancelled',  (Amount)))) + (Sum(IF(Status = 'Booked',  (Amount))))

sum( {<Status={'Cancelled'},Status={'Booked'}>}Amount)

Could you please tell me why they are giving different results?

15 Replies
tresesco
MVP
MVP

Suraj,

Set analysis is meant for that. In the expression: sum( {<Status={'Cancelled'},Status={'Booked'}>}Amount)

you specifically say the values to be considered for field Status.  Hence, it ignores the selection for that field.

SunilChauhan
Champion II
Champion II

first one is showing correct result

and second one is overriding the status to Booked.

changed the order of booked and cancelled  in second expression.

it will give other result.

i mean to say it taking last one status and showing value on that.

hope this helps

Sunil Chauhan
sudeepkm
Specialist III
Specialist III

Given below is a screenshot of what I tested in my sample Application.

As you can see when I have the expression {<Field={'value1', 'value2'} >} it considers as either or that means all from both the selection.

when I gave the expression like {<Field={'value1'},Field={'value2'} >} it considers it as two selections of same field but one after another. and finally it considers the second selection. this is same response when we select a value from a list box and then we select another value from the same list box. the first selection is overridden by the second selection.

T117348.png 

surajap123
Creator III
Creator III
Author

Thanks a lot to everyone for explaining it so well, especially tresesco and sudeep

preminqlik
Specialist II
Specialist II

you can use the following expressions :

Sum(IF(Status = 'Cancelled' or Status = 'Booked',  Amount)

or

sum( {<Status={'Cancelled' , 'Booked'}>}Amount)

Joseph_Musekura
Support
Support

Hi,

I agree with Sudeep,

sum( {<Status={'Cancelled','Booked'}>}Amount), this will returns both selections

If you add 1

sum( {1<Status={'Cancelled', 'Booked'}>}Amount), it will disregard any selection made

Regards,