9 Replies Latest reply: Feb 9, 2017 8:51 AM by Mitch Boyer

# Intersection of a selection

Hello,

I'm new on Qlik Sense and I have a problem.

I have a delivery number. There are multiple products linked to the delivery number.

I have a list of products.

When I select a product in the list, I would like my bar chart to show me, how many delivery numbers the product I selected has in common with each of the other products.

I hope I was clear enough,

Thank you,

• ###### Re: Intersection of a selection

It would be helpful if you can share a sample with expected output to help you better here

• ###### Re: Intersection of a selection

Hi Gaeten,

What i understood by your concern, Lets say there are 5 products A,B,C..E and a delivery number 100 and scenario is, If you select a product A then Number will be 20 and 20 is a number calculated or associated by A or C .

Above is just an example .

Can you correct me If I am wrong.

• ###### Re: Intersection of a selection

Here is an example:

Delivery Number          Products

123                             A ; C ; D

124                             A ; B

125                             B ; C ; E

126                             A ; B ; D

127                             A ; D ; E

When I select product A, I want the bar for B to show me 2 because they have two delivery numbers in common

the bar for C will show 1

the bar for D will show 3

...

I hope this is clear enough,

Thank you,

• ###### Re: Intersection of a selection

Hi Geetan,

Still not cleared. What do you mean by delivery number in common. Secondly, How can you have A ; C ; D in one single entity . Can you attach the sample data in csv or excel please ?

• ###### Re: Intersection of a selection

SCRIPT

D:

deliverynumber  ,       product

123                ,             A ; C ; D

124                  ,           A ; B

125                 ,            B ; C ; E

126                   ,          A ; B ; D

127                    ,         A ; D ; E

];

D1:

NoConcatenate

load deliverynumber, trim(SubField(product, ';')) as product

Resident D;

DROP Table D;

CHART

count({\$ <product=,deliverynumber=P({<product=P(product)>} deliverynumber)>} deliverynumber)

• ###### Re: Intersection of a selection

Thank you Massimo, this is exactly what I was looking for !

• ###### Re: Intersection of a selection

It appears that this works, but I have another request that's related:

If I select two selections in [product], how can I get a count of deliverynumbers that have BOTH selections? Right now, it gives me the union, not the intersection.

Thanks!

• ###### Re: Intersection of a selection

May be check this link out:

AND-Mode

• ###### Re: Intersection of a selection

Perfect! Thanks for your help again Sunny!