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

Intersection between selected set

Hi,

I have a data set that looks like this

receiptId prodcutId
1 A, B, C
2 A, B
3 B, C
4 A, D

 

I want the count of the products that are occurring at the same receipt as the products currently selected. So if  A is selected the resulting graph should show be A=2, B=2, C=1 D=1 .

17.png

I have done theis with the expression: count({<productId=, receiptId=P({<productId=P(productId)>} receiptId)>} receiptId)

 

My problem is that I can't figure out how to get the count if i select multiple productIds. For example if both A and B are selected the intersected receipt should be 1 and 2 and the graph displaying be A=2 B=2 and C=1. Currently, my expression gives the union between A and B which in this case means all recieptId and the graph shows A=3, B=3, C=2, D=1.

15.png

So how do I get the count of product for multiple selection?

2 Replies
Channa
Specialist III
Specialist III

try to load data 

receiptid, productid

1,A

1,B

1,C

2,A

2,B

 

LOAD
receiptid
Subfield(productid,',') as prod
Resident ;

Channa
PalAlexandersson
Employee
Employee
Author

Yes, that is how I load the data.

I'm not I explained it properly.  My problem is that I need to have the count of all products of the selected product which have intersecting receipt id.

My set is on 100k products which mean there is >10^100000 possible combination, so it is not feasible to do the calculations in my load script.

Something like an measure expression like count(({<productId(first selected product)=, receiptId=P({<productId=P(productId)>} receiptId)>} receiptId)*{<productId(second selected product)=, receiptId=P({<productId=P(productId)>} receiptId)>} receiptId)*third product