Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Sales Overlap / Intersection problem

Hi all,
Consider the following table of products sold to various customer categories. Some of the products are exclusive to one customer category, hence only appearing once, and other products are shared among two or more categories:
Product NumberCustomer Category

1001

Window manufacturer
1002Door manufacturer
1003Floor manufacturer
1004Floor manufacturer
1005Decking manufacturer
1006Contractor
1007Contractor
1007Floor manufacturer
1008Wholesale
1009Wholesale
1009Floor manufacturer
1009Door manufacturer
1009Contractor
1010Door manufacturer
1011Contractor
1012Floor manufacturer
1012Door manufacturer
Now I want to find out the number of distinct products (for each customer category) that are shared between customer categories, displayed on customer category. In fact the follwing table:
Customer Category# of distinct articles that are shared by at least one other customer category
Window manufacturer0
Door manufacturer2
Floor manufacturer2
Decking manufacturer0
Contractor2
Wholesale2
I have tried the follwing expression in a straight table but it doesn't seem to be working:

Count(DISTINCT If(Aggr(Count (DISTINCT [Customer Category]), [Product Number])>1, [Product Number] ) )

Could someone give me a push in the right direction?

Thank you,

David

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

I got it - see attached.

Expresion is using set, and I created a variable with another expression.

Regards,

Michael

View solution in original post

12 Replies
Anonymous
Not applicable
Author

Maybe this (assuming that Customer Category is table dimension):

if(count(distinct [Product Number])=1, 0, count(distinct [Product Number]))

Not applicable
Author

Hi Michael,

Thanks for your reply!

However the suggested result does not render the expected outcome.

BR,

David

Anonymous
Not applicable
Author

David, what are you getting?

Not applicable
Author

Sorry for the messy tables, but this is what I am getting:

Categoryif(count(distinct [Product])=1,
  0, count(distinct [Product]))
Contractor4
Door
  manufacturer
4
Floor
  manufacturer
5
Wholesale2

With my above suggestion I get the following:

CategoryCount(DISTINCT If(Aggr(Count
  (DISTINCT Category), Product)>1, Product ) )
Contractor1
Floor
  manufacturer
1
Wholesale1

Thanks,

Not applicable
Author

I just realized I made a mistake in the expected outcome. So this is what I want it to look like:

Category                         #of distinct articles shared by other categories

Window manufacturer     0

Door manufacturer          2          (product nr: 1009, 1012)

Floor manufacturer          3          (product nr: 1007, 1009, 1012)

Decking manufacturer     0

Contractor                       2           (product nr: 1007, 1009)

Wholesale                       1           (product nr: 1009)

Sorry for the mishap

Anonymous
Not applicable
Author

I just understood what you want - count products per Category, but include only the Products which exist in more than one Category.

Is it correct?

Not applicable
Author

Correct! The count of distinct products that exists in more than one category displayed per category

Anonymous
Not applicable
Author

I got it - see attached.

Expresion is using set, and I created a variable with another expression.

Regards,

Michael

Not applicable
Author

Thank you Michael!!

Works like a charm 🙂