Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Multiple Count( IF statements

Hi

My data has the following structure for transactions:

ID Customer Item Date

I am developing a graph that analyses how many buyers are active, how many are lapsed and how many were reinstated.

For the active buyers I am using the following statement in the expression of a bar chart:

=COUNT(DISTINCT IF(Inmonth(Date,now(),-1),Customer,null()))

For the lapsed ones I would like to select all that did not buy in the last three months, but I can't figure out how.

For the reinstated ones I would like to count how many customers have purchased in the last month, although they had not purchased anything in the previous 3 months. I just can't find the way to do this either.

Any suggestions?

1 Reply
jedgson
Creator
Creator

You could create a flag in the Script

Temp_Map:Mapping LoadCustomer,max(Date)from DataSourceGroup By Customer;

LoadID,Customer,Item,Date,if(applymap('Temp_Map', Customer) >= addmonths(today(),-3),1,0) as PurchasedInLast3MonthsFlagfrom DataSource;


You can then use then use the flag in the chart