Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Differences between subsets in an expression

Hi,

I'm trying to calculate the difference in counts of customers between two sets in an expression i.e. comparing two months worth of data:

Customer_IDCustomer_NameTransaction_DateMonthNameFlag
1234Mr X01/03/2016Mar 2016N
5678Mrs Y01/03/2016Mar 2016Y
1435Mr Z12/03/2016Mar 2016N
4321Mr A12/03/2016Mar 2016Y
5371Mrs B31/03/2016Mar 2016N
7671Ms C31/03/2016Mar 2016N

9003Mr Q01/04/2016Apr 2016N
Customer_IDCustomer_NameTransaction_DateMonthNameFlag
1234Mr X01/04/2016Apr 2016N
4321Mr A12/04/2016Apr 2016Y
7671Ms C30/04/2016Apr 2016N
9897Ms P30/04/2016Apr 2016Y

I'm essentially trying to calculate the difference in the number of customers that appear in April that were not present in March. I'm finding it difficult to structure the syntax in this expression however as a distinct count of set B - set A. Would any Qlik users out there have any experience in trying to put together something similar?

I have one calculation in my sheet that calculates a distinct count of customer ID in Set B and subtracts it from Set A, i.e. Count(DISTINCT{<MonthName = {"Apr 2016"}>}Customer_ID)- Count(DISTINCT{<MonthName = {"Mar 2016"}>}Customer_ID), but here I want to subtract the rows in Set B where the Customer_ID or Customer_Names are identical between the two months and then perform a distinct count on the remaining rows, i.e. the answer should be 2 if Mr X, Mr A and Ms C are excluded.

Many thanks,

Sarah

2 Replies
swuehl
MVP
MVP

Try

=Count(DISTINCT {<MonthName ={'Apr 2016'}, Customer_ID = e({<MonthName = {'Mar 2016'}>})>}Customer_ID)

Anonymous
Not applicable
Author

Many thanks Stefan, that worked well!


Mit freundlichen Grüßen,

Sarah