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
SunilChauhan
Champion II
Champion II

this may help

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

-

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

Sunil Chauhan
Not applicable
Author

Thank you,

unfortunately the result is the same, the pivot table is not filtered by the expression.

For info, the two variables contain thow set of customer ID calculated though "concat" function.

I don't understand if it is the "only" function not used in a correct way or the subtraction not possible between the two variables.

SunilChauhan
Champion II
Champion II

sum({$<CustomeID={$(var_customed_id_selected)}}>}distinct Exhibition_edition)

-

sum({$<CustomeID={{$(var_customer_id_excluded)}>} distinct Exhibition_edition)

Sunil Chauhan
Not applicable
Author

Nothing yet

lironbaram
Partner - Master III
Partner - Master III

hei

what is the dimension of the pivot table

i thimk you can use the E() and P() function in set analsys

But i need better understanding of the pivot table structre

if you can post some sample data it would be great

SunilChauhan
Champion II
Champion II

there was syntax error in above.please try this

sum({$<CustomeID={$(var_customed_id_selected)}>}distinct Exhibition_edition)

-

sum({$<CustomeID={$($(var_customer_id_excluded)}>}distinct Exhibition_edition)

thanks

Sunil Chauhan

Sunil Chauhan
Not applicable
Author

I saw that and I've already wrote that in the correct way.

No success yet.

Not applicable
Author

Well: the dimensions of the pivot table are the name of the customer, the name of the exhibition (concatenated with the edition) of the exhibition to which he participated, city and country of the customer.

Among the expressions, the calculation about exhibitor or visitor status of the customer, based on a certain set of rules on his past participations.

The dimension on which I'd like to rule the set analysis is the exhibition edition to which the customer has participated.

The logic is the sequent:

- I set the first variable T1 with all customerdID acutally selected into the document, where CustomerID field is linked to all other data inside the data model;

- I set the second variable T2 with the CustomerID to be excluded: these ID belong to a different table not linked with the rest of data model.

So, I want to filter on edition dimension, CustomerID that have participated to an exhibition (T1) minus CustomerID excluded by a list-box apart (T2) e subtract T1- T2 on the dimension.

johnw
Champion III
Champion III

I think it's much simpler than all that.  I think this would work, no variables required:

{<CustomerID-=TheOtherCustomerIDField>}

Assuming I got the syntax correct, that expression says "Give me the customer IDs that I selected but exclude the ones I selected in the other customer ID field."  However, I have no idea what you're doing with the only() or the sum() or what you're actually trying to accomplish, so merely plugging that set expression in to your expressions may not do what you want it to do.