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

Announcements
Now accepting applications for the Qlik Luminary and Partner Ambassador Programs: Apply by July 6!
cancel
Showing results for 
Search instead for 
Did you mean: 
PabloMC
Contributor II
Contributor II

if condition inside Set analysis

Hi, 

I have a table with values like the following (simplified example):

 
Country    ProductId    Sales
Spain      1            100
France     1            100
England    1            100
Portugal   1            100
Spain      2            50
France     2            50
England    2            50
Portugal   2            50

What I need is a Set Analysis expression where:

  • For France, only ProductId = 1 should be included

  • For all other countries, all ProductId values should be included

I know I can do something like:

 
If(Country = 'France', Sum({<ProductId={1}>} Sales), Sum(Sales))

…but I do not want to use an if() outside the Set Analysis. I want the logic to be fully inside the Set modifier.

Something like this (which I know does not work):

 
Sum({<ProductId = {if(Country='France', 1, '*')}>} Sales)

Is it possible to pass this conditional logic directly into the Set Analysis?

My goal is to avoid row‑level if() and keep everything inside the set.

 

Thanks

Labels (3)
2 Replies
Or
MVP
MVP

It seems like it would be much easier to just use two sums - one for France and one for everything else - and add those?

That said, the set analysis shouldn't be a problem using the union (+) operator and excluding France from one half:

{$<country -= {'France'}> + <country = {'France'}, ProductId = {1}>}

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

How about below?

 

Sum({<Country={'France'},ProductId = {1}>+<Country-={'France'}>} Sales)

  

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.