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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to know if a value is inside a filter

I have a table XXXX where the field YYYY has different values.

In a graphic I want to do some calculations depending on if the YYYY field contains one value or not, for example:

IF (YYYY = 'A',sum(ZZZZ)*0.115,sum(ZZZZ)*0.985)


But when I have filtered different values on YYYY field that conditional does not work.

I need one expression similar to Contains.

Thank you in advance.

5 Replies
Anonymous
Not applicable
Author

sum(ZZZZ * if(YYYY='A', 0.115, 0.985))

Not applicable
Author

Thanks Michael, but it didn't work because when I have all the values selected in a Filter I only want to sum a set of values with 0.985, and another set of values with 0.015 and it sums always with 0.985.

I am trying to load the calcs in a resident table using the following script

load

     If(Tipo = 'YYYY' and Code = 'A1', sum(ZZZZ)) as "Value 1",

     If(Tipo = 'TTTT' and Code = 'A1', sum(ZZZZ)) as "Value 2",

Resident XXXX;

But I have got the error "Invalid expression", Have I to iterate on everyrow of the XXXX table?

Thanks.

tresesco
MVP
MVP

Sum() is an aggregation function which requires Group By clause in the script.

Anonymous
Not applicable
Author

Alexis,

Tres explained why you get the error.

Still there are questions.  It's not quite clear what you want.  Maybe you can upload an example with explanations.

One more attempt, after re-reading your opening post, and disregarding your original expression.  If "contains" is the key here, try this (not in the script but on the front end):

if(wildmatch(concat(distinct YYYY,','), '*A*'), 0.115 , 0.985) * sum(ZZZZ)

Regards,

Michael

maxgro
MVP
MVP

=if(count(DISTINCT {1 <YYYY ={'A'}>} YYYY )=1, sum(ZZZZ)*0.115,sum(ZZZZ)*0.985)