Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
micheledenardi
Specialist II
Specialist II

List of customers who bought product A and B but not C

Hi Experts,

i would like to write an expression which shows the total amout of customers that bought product A and B but not C.

Load * Inline [
Customer,Product
CUST1,A
CUST1,B
CUST2,A
CUST3,B
CUST4,A
CUST4,B
CUST4,C
CUST5,C
];

I wrote this expression and it works but unfortunatelly the result cannot be summed so the "total" of my table is = 0 and if i try to put this expression in a KPI it returns 0 and i would like to see the customer count.

=fabs(count({<Product={'A'}>}Customer)>0 and count({<Product={'B'}>}Customer)>0 and count({<Product={'C'}>}Customer)<=0)

How to fix it ?

The  result of this expression with above dataset must be 1 (so only CUST1).

 

Michele De Nardi
If a post helps to resolve your issue, please accept it as a Solution.
1 Solution

Accepted Solutions
sunny_talwar

May be try this

 

Count(DISTINCT {<Customer = p({<Product = {'A'}>})*p({<Product = {'B'}>})*e({<Product = {'C'}>})>} Customer)

 

View solution in original post

3 Replies
ajaykakkar93
Specialist III
Specialist III

Hi,

Customer Count : Count({<Product={'A','B'}>}Customer)

Product                  CustomerCount

A                                3

B                                3

Is this the expected output then 

In table add Product Dimension & in Measure add If condition

if(Product='A',count(Customer),
if(Product='B',count(Customer)))

 

In add-ons -> data handling -> uncheck include null values.

 

 

 

 

Please mark the correct replies as Solution. Regards, ARK
Profile| GitHub|YouTube|Extension|Mashup|Qlik API|Qlik NPrinting

sunny_talwar

May be try this

 

Count(DISTINCT {<Customer = p({<Product = {'A'}>})*p({<Product = {'B'}>})*e({<Product = {'C'}>})>} Customer)

 

Vikash938
Contributor III
Contributor III

I need to check what if some customer buy  both product then how we can write the script in qlik sense