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: 
spividori
Specialist
Specialist

Select customers with movements in two periods.

Hi.

I need to identify the customers who bought in two periods and exclude those who bought in one and not in another.
In my example, Periods: 2018 and 2010, I use the following expression:

if(Sum({<[Año]={2019}>} Cantidad)>0 and Sum({<[Año]={2018}>} Cantidad)>0,Sum(Cantidad))

Work almost perfect. Customers who did not buy in some period show them void. But the total is equal to the sum of all.

Captura.JPG

Regards.

Labels (1)
1 Solution

Accepted Solutions
Anil_Babu_Samineni

Perhaps this

Sum(Aggr(if(Sum({<[Año]={2019}>} Cantidad)>0 and Sum({<[Año]={2018}>} Cantidad)>0,Sum(Cantidad)), Cust))

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful

View solution in original post

3 Replies
Anil_Babu_Samineni

Perhaps this

Sum(Aggr(if(Sum({<[Año]={2019}>} Cantidad)>0 and Sum({<[Año]={2018}>} Cantidad)>0,Sum(Cantidad)), Cust))

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
spividori
Specialist
Specialist
Author

Sorry for the delay. It works perfect. But I have another problem, when I put that formula by month it doesn't separate it by year. Place the total in a single column.

Captura.JPG

Regards.

Anil_Babu_Samineni

You have to include all dimensions from the report, If only one you can simply use one dimension on the Aggregate function.

Sum(Aggr(if(Sum({<[Año]={2019}>} Cantidad)>0 and Sum({<[Año]={2018}>} Cantidad)>0,Sum(Cantidad)), Cust, Month))

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful