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

Subtract two variables inside a set analysis

Hi all,

I'm trying to filter the content of a pivot table using a set analysis on a dimension, filtered by another dimension calculated on values obtained by the subtraction of two variables.

Example:

only({$<CustomeID={$(var_customed_id_selected)}-{$(var_customer_id_excluded)}>} Exhibition_edition)

Inside my pivot table I'd like to view customer's exhibition participation, but only for those customers selected minus customer excluded.

The set of customers excluded is obtained through another customer table not linked in the data model.

The pivot table is not filtered..

Any tips?

Thanks a lot,

Alessandro.

20 Replies
perumal_41
Partner - Specialist II
Partner - Specialist II

only({$<CustomeID={$(=$(var_customed_id_selected)}-{$(var_customer_id_excluded))}>} Exhibition_edition). try this code

lironbaram
Partner - Master III
Partner - Master III

hei attach is an example

what i did is reloading the customer list twice

when you select customer in the list box on the right side

it will exclude then from the table

i am using the expression

{<CustomerID=-P(CustID2)>} which mean Exluding the Possible Client from CustID2

hope its helps you

Not applicable
Author

Thank you John, I tried your solution without success.

I know what I have to do but I've got no clear how to do it.

I tried all the solutions posted here but no result yet.

If I have an idea or an improvement I'll surely post it.

Not applicable
Author

Maybe I'm near the solution but I've got a question: inside my pivot table, if my expression (I changed the "only" with a "count") returns two possible values, '0' and '1', and I want to show only the '1's , how can I do that?

I checked the option "Suppresso zero-values" on Presentation folder of the expression with no result.

Not applicable
Author

Any suggestion about deleting rows from a pivot table in which the value of my expression return 0?

Thanks,

Alessandro.

Not applicable
Author

Hi all,

I found the solution to my problem, in this expression:

if(GetSelectedCount(exhibition_name_excluded)>0 or GetSelectedCount(exhibition_edition_excluded)>0,

count({$<CustomerID={$(var_CustomerID_selected)}-{$(var_CustomerID_excluded)}>} Exhibition_edition),'2')

"exhibition_name_excluded" and "exhibition_edition_excluded" are the fields through which the user can choose the exhibition name or the exhibition edition to exclude. These fields are linked to the CustomerID_excluded inside the data model.

Once the exclusion is choosen, in my pivot table I show only the exhibiton edition (Exhibition_edition) filtered by set analysis {$<CustomerID={$(var_CustomerID_selected)}-{$(var_CustomerID_excluded)}>}

Inside the variable "var_CustomerID_selected" there are all the possible CustomerID (selected through CONCAT function) available in the document.

Inside the variable "var_CustomerID_excluded" there are all the excluded CustomerID (selected through CONCAT function), linked in the data model to the exhibitions exluded by the user.

The solution is good but with 600.000 CustomerID in my DB, the subtraction between the two variables and the calculation of the pivot table are too heavy for the server (Intel Xeon E7330@2.82 GHZ, 2 processors).

Any suggestions about that?

I was thinking to eliminate the two variables and subtract the CustomeID and CustomerID_excluded directly inside the set analysis, something like this:

if(GetSelectedCount(exhibition_name_excluded)>0 or GetSelectedCount(exhibition_edition_excluded)>0,

count({$<CustomerID={$(Chr(39) & concat(distinct Chr(39) & CustomerID, Chr(39) & ',' ) & Chr(39)) - {(Chr(39) & concat(distinct Chr(39) & CustomerID_escl, Chr(39) & ',' ) & Chr(39)) Exhibition_edition),'2')

The syntax doesn't work. Any suggestions?

SunilChauhan
Champion II
Champion II

prsesentation-> check on supress zero value

or

if( FieldName<>0,FieldName)

Sunil Chauhan
Not applicable
Author

Hi all,

the solution I described before works correctly but the performances decrease massively and the application is not usable.

I thought the problem was storing a great number of customerID into the two variables and then subtract them.

Anyone can suggest me an alternative solution through which I can subtract from the possibile values (not only the selected ones) of an ID inside the document the values of another ID (in this case those selected)?
I'd need to filter the data linked to the ID resulting from the previous subtraction, inside a pivot table.

Not applicable
Author

Any suggestions?

Actually my set analysis is:

if(GetSelectedCount(Id_Of_Exhibition_To_Exclude)>0 or GetSelectedCount(Id_Of_Edition_Of_Exhibition_To_Exclude)>0,

count({$<Customer_ID={$(VAR_Possible_Customer_ID)}-{$(VAR_CustomerID_To_Exclude)}>} EditionOfExhibition),'2')

The CustomerID to exclude are taken by a secondary table in the data model, not linked to the "cloud".

In this way, independently from the selection of the customerID inside the document, the user can select which Customer (Exhibition) to exclude, taken from another table and so not influenced by other selection.

It works but the subtraction between the two variables is too heavy as I sad in the previous posts.

I'm looking for an alternative set analysis with better performance.

Anyone?

Thank you.

SunilChauhan
Champion II
Champion II

go to presentation and check supress zero values

or

If(expression>0,expression)

where expression is formula written

or clear mee if i am wrong

thanks

Sunil

Sunil Chauhan