Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to select the market baskets with both products

I need to make a sample with only the market baskets that have necessarily both products X and Y. I don't want the baskets tha have only X or Y. See the attachment, in green are the baskets I want.

I'm working with csv files in Qlik Sense.

4 Replies
sunny_talwar

Do you want to flag them or remove them in the script? By flagging you would be able to call just those rows which meet your criteria, while still having them in the application to use elsewhere. By removing, you would just have the desired rows and rest all will be removed, assuming they are not needed in the application anywhere.

Not applicable
Author

Sunny, thank you for helping. I'd like a way that is easier for the end user. But if I use flag, how should be the script to exactly meet the criteria? I'm using csv files.

sunny_talwar

Here is how the flags will look like:

Capture.PNG

Script:

Table:

LOAD * Inline [

Cesta, Produto, Quantidade

1, y, 3

1, x, 5

1, z, 2

2, x, 3

2, j, 7

3, y, 1

4, x, 2

5, z, 1

6, x, 10

6, y, 5

];

Left Join(Table)

LOAD Cesta,

  If(Sum(If(Match(Produto, 'y', 'x'), 1, 0)) = 2, 1, 0) as Flag

Resident Table

Group By Cesta;

Not applicable
Author

Sunny, thank you! That Helped a lot!