Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Marcoimp
Partner - Creator III
Partner - Creator III

Ancora Set Analisys

Ho un certo numero di clienti che hanno comprato il prodotto A, alcuni il prodotto B, altri sia il prodotto A che il B....

come faccio a contarli?

Solo A:

COUNT({<MyTstTipo={A}, Cliente-=P({<MyTstTipo={B}>} Cliente)>} DISTINCT Cliente)

Solo B:

COUNT({<MyTstTipo={B}, Cliente-=P({<MyTstTipo={A}>} Cliente)>} DISTINCT Cliente)


Giusto?

Ma per quelli che hanno comprato tutt'e due come si fa?

M.Imperiale
5 Replies
jduarte12
Partner - Creator II
Partner - Creator II

Marco,

I manage to understand italian (latin language, like portuguese), but I do not speak/write italian, so my answer will be in english. I hope that's not a problem.

You may try:

COUNT({<MyTstTipo={A,B}, Cliente-=P({<MyTstTipo={A,B}>} Cliente)>} DISTINCT Cliente)


Best regards

jduarte12
Partner - Creator II
Partner - Creator II

The set analysis I suggested before will return "A or B".

In order to get "A and B", it may be better to try:

COUNT({<MyTstTipo={B}, Cliente-=P({<MyTstTipo={A}>} Cliente)>*<MyTstTipo={A}, Cliente-=P({<MyTstTipo={B}>} Cliente)>} DISTINCT Cliente)

Marcoimp
Partner - Creator III
Partner - Creator III
Author

No: in your example I will get 0, because I ask for Clients both with only "A" AND with only "B".... impossibile.

M.Imperiale
Marcoimp
Partner - Creator III
Partner - Creator III
Author

I have some clients that purchased product "A" and some other product "B", some other purchased "A" and "B", how can I count them?

Only A:

COUNT({<MyTstTipo={A}, Cliente -=P({<MyTstTipo={B}>} Cliente)>} DISTINCT Cliente)

Only B:

COUNT({<MyTstTipo={B}, Cliente -=P({<MyTstTipo={A}>} Cliente)>} DISTINCT Cliente)


Is it right?

But how can I count who purchased both products?

M.Imperiale
Marcoimp
Partner - Creator III
Partner - Creator III
Author

EUREKA!

Here the answer:

COUNT({<MyTstTipo={A}, Cliente =P({<MyTstTipo={B}>} Cliente)>} DISTINCT Cliente)

I.E.

Count every Client with MyTstTipo="A" that is in group of all clients with MyTstTipo="B"

M.Imperiale