<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Customer loyalty based on months since last activity in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Customer-loyalty-based-on-months-since-last-activity/m-p/1757198#M720534</link>
    <description>&lt;P&gt;Customers:&lt;BR /&gt;LOAD 'Customer-'&amp;amp;floor(Rand()*5000) as Customer,&lt;BR /&gt;Date(Today() - Floor(Rand()*720)) as PastDates&lt;BR /&gt;AutoGenerate (5000);&lt;/P&gt;&lt;P&gt;Customer2:&lt;BR /&gt;NoConcatenate load&lt;BR /&gt;Customer,&lt;BR /&gt;if( PastDates &amp;gt;= addmonths(today(),-13),1,0) as Last13Months,&lt;BR /&gt;if( PastDates &amp;gt;= addmonths(today(),-12) and PastDates &amp;lt; addmonths(today(),-1) ,1,0) as Between1_12Months,&lt;BR /&gt;if( PastDates &amp;gt;= addmonths(today(),-26) and PastDates &amp;lt; addmonths(today(),-13) ,1,0) as Between26_13Months,&lt;BR /&gt;if( PastDates &amp;gt;= addmonths(today(),-18) and PastDates &amp;lt; addmonths(today(),-13) ,1,0) as Between18_13Months,&lt;BR /&gt;if( PastDates &amp;gt;= addmonths(today(),-24) and PastDates &amp;lt; addmonths(today(),-18) ,1,0) as Between24_18Months,&lt;BR /&gt;if( PastDates &amp;gt;= addmonths(today(),-1),1,0) as LastMonth,&lt;BR /&gt;if( PastDates &amp;lt; addmonths(today(),-24), 1,0) as Olderthan24months&lt;BR /&gt;resident Customers;&lt;/P&gt;&lt;P&gt;Drop Table Customers;&lt;/P&gt;&lt;P&gt;Customers:&lt;BR /&gt;load&lt;BR /&gt;Customer,&lt;BR /&gt;if(sum(Last13Months) &amp;gt;=1 and sum(Between26_13Months) &amp;gt;=1, 'Retained Customer',&lt;BR /&gt;if(sum(Last13Months) &amp;gt;=1 and sum(Between26_13Months) =0 and sum(Olderthan24months) =0, 'New Customer',&lt;BR /&gt;if(sum(Between18_13Months) &amp;gt;=1 and sum(Last13Months) =0, 'Lapsed Customer',&lt;BR /&gt;if(sum(Between18_13Months) &amp;gt;=1 and sum(LastMonth) &amp;gt;=1 and sum(Between1_12Months) =0, 'Returning Customer',&lt;BR /&gt;if(sum(Between24_18Months) &amp;gt;=1 and sum(Last13Months) =0 and sum(Between18_13Months) =0, 'Lost Customer'))))) AS LoyaltyBracket&lt;BR /&gt;resident Customer2&lt;BR /&gt;group by Customer;&lt;/P&gt;&lt;P&gt;Drop table Customer2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You then left join this table on the original Table, to fit your requirement as I understand it. You would be able to filter on Date and get order data with customer ID's and Loyalty Brackets.&lt;/P&gt;</description>
    <pubDate>Thu, 29 Oct 2020 21:42:04 GMT</pubDate>
    <dc:creator>Martijn_W</dc:creator>
    <dc:date>2020-10-29T21:42:04Z</dc:date>
    <item>
      <title>Customer loyalty based on months since last activity</title>
      <link>https://community.qlik.com/t5/QlikView/Customer-loyalty-based-on-months-since-last-activity/m-p/1757157#M720532</link>
      <description>&lt;P&gt;Hi Qlik Experts.&lt;/P&gt;&lt;P&gt;I'm very new to Qliksense and have been struggling to categorize customers into loyalty segments based on activity in previous months.&lt;/P&gt;&lt;P&gt;I would like to select a month and year from filter pane and display the below:&lt;/P&gt;&lt;P&gt;Fields in Table: CustomerID, Date (DD/MM/YYYY)&lt;/P&gt;&lt;P&gt;New Customers- New Customer ID's within last 13 months&lt;/P&gt;&lt;P&gt;Retained customers - Existing Customer ID's that are active in last 13 months and previous 13 month period before that&lt;/P&gt;&lt;P&gt;Lapsed Customers - Customer ID's with activity between 13-18 months ago but have not returned&lt;/P&gt;&lt;P&gt;Returning Customer - Customer ID's that were previously lapsed but have now returned&lt;/P&gt;&lt;P&gt;Lost Customer - Customer ID's with last activity between 18-24 months ago who have not returned&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately due to access rights I cannot import an app so I would appreciate any help on the script to be pasted here. Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Customer-loyalty-based-on-months-since-last-activity/m-p/1757157#M720532</guid>
      <dc:creator>QlikNewbie20</dc:creator>
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Customer loyalty based on months since last activity</title>
      <link>https://community.qlik.com/t5/QlikView/Customer-loyalty-based-on-months-since-last-activity/m-p/1757196#M720533</link>
      <description>&lt;P&gt;i think it may need to be a multi step process. share some sample data and should be able to give you full logic .&lt;/P&gt;&lt;P&gt;but&amp;nbsp;essentially you create multiple steps for each category and use that to load a single category column in a new table.&lt;/P&gt;&lt;P&gt;roughly (havent tested but should give you a starting point)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Category:
load distinct
CustID
,'New' as Category

where Min&amp;gt;addmonths(today(),-13);
load CustID
, Min(Date) as Min
resident Customer
group by CustID;

//Lapsed
Concatenate(Category)
load distinct
CustID
,'Lapsed' as Category
//last order between 13 and 18 months ago
where Max&amp;lt;=addmonths(today(),-13) and Max&amp;gt;=addmonths(today(),-18); 
load CustID
, Max(Date) as Max
resident Customer
group by CustID;

//retained
Concatenate(Category)
load CustID
,'Retained' as Category
//All Order in last 26 months
// latest order in last 13 months and at least 1 order in 13 months before that

where Max&amp;gt;addmonths(today(),-13) and Min &amp;lt;addmonths(today(),-13) 
;
load CustID
, Max(Date) as Max
,Min(Date) as Min
group by CustID
;
load *
resident Customer
where Date&amp;gt;addmonths(today(),-26)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2020 21:27:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Customer-loyalty-based-on-months-since-last-activity/m-p/1757196#M720533</guid>
      <dc:creator>dplr-rn</dc:creator>
      <dc:date>2020-10-29T21:27:46Z</dc:date>
    </item>
    <item>
      <title>Re: Customer loyalty based on months since last activity</title>
      <link>https://community.qlik.com/t5/QlikView/Customer-loyalty-based-on-months-since-last-activity/m-p/1757198#M720534</link>
      <description>&lt;P&gt;Customers:&lt;BR /&gt;LOAD 'Customer-'&amp;amp;floor(Rand()*5000) as Customer,&lt;BR /&gt;Date(Today() - Floor(Rand()*720)) as PastDates&lt;BR /&gt;AutoGenerate (5000);&lt;/P&gt;&lt;P&gt;Customer2:&lt;BR /&gt;NoConcatenate load&lt;BR /&gt;Customer,&lt;BR /&gt;if( PastDates &amp;gt;= addmonths(today(),-13),1,0) as Last13Months,&lt;BR /&gt;if( PastDates &amp;gt;= addmonths(today(),-12) and PastDates &amp;lt; addmonths(today(),-1) ,1,0) as Between1_12Months,&lt;BR /&gt;if( PastDates &amp;gt;= addmonths(today(),-26) and PastDates &amp;lt; addmonths(today(),-13) ,1,0) as Between26_13Months,&lt;BR /&gt;if( PastDates &amp;gt;= addmonths(today(),-18) and PastDates &amp;lt; addmonths(today(),-13) ,1,0) as Between18_13Months,&lt;BR /&gt;if( PastDates &amp;gt;= addmonths(today(),-24) and PastDates &amp;lt; addmonths(today(),-18) ,1,0) as Between24_18Months,&lt;BR /&gt;if( PastDates &amp;gt;= addmonths(today(),-1),1,0) as LastMonth,&lt;BR /&gt;if( PastDates &amp;lt; addmonths(today(),-24), 1,0) as Olderthan24months&lt;BR /&gt;resident Customers;&lt;/P&gt;&lt;P&gt;Drop Table Customers;&lt;/P&gt;&lt;P&gt;Customers:&lt;BR /&gt;load&lt;BR /&gt;Customer,&lt;BR /&gt;if(sum(Last13Months) &amp;gt;=1 and sum(Between26_13Months) &amp;gt;=1, 'Retained Customer',&lt;BR /&gt;if(sum(Last13Months) &amp;gt;=1 and sum(Between26_13Months) =0 and sum(Olderthan24months) =0, 'New Customer',&lt;BR /&gt;if(sum(Between18_13Months) &amp;gt;=1 and sum(Last13Months) =0, 'Lapsed Customer',&lt;BR /&gt;if(sum(Between18_13Months) &amp;gt;=1 and sum(LastMonth) &amp;gt;=1 and sum(Between1_12Months) =0, 'Returning Customer',&lt;BR /&gt;if(sum(Between24_18Months) &amp;gt;=1 and sum(Last13Months) =0 and sum(Between18_13Months) =0, 'Lost Customer'))))) AS LoyaltyBracket&lt;BR /&gt;resident Customer2&lt;BR /&gt;group by Customer;&lt;/P&gt;&lt;P&gt;Drop table Customer2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You then left join this table on the original Table, to fit your requirement as I understand it. You would be able to filter on Date and get order data with customer ID's and Loyalty Brackets.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2020 21:42:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Customer-loyalty-based-on-months-since-last-activity/m-p/1757198#M720534</guid>
      <dc:creator>Martijn_W</dc:creator>
      <dc:date>2020-10-29T21:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: Customer loyalty based on months since last activity</title>
      <link>https://community.qlik.com/t5/QlikView/Customer-loyalty-based-on-months-since-last-activity/m-p/1757235#M720535</link>
      <description>&lt;P&gt;Hi dilipprajinth.&lt;/P&gt;&lt;P&gt;Thanks for quick reply.&lt;/P&gt;&lt;P&gt;I seem to get an error in the last bit of script. I assumed to&amp;nbsp; rewrite as below but I then get an error saying "Date" field not found&lt;/P&gt;&lt;P&gt;load CustID&lt;/P&gt;&lt;P&gt;resident Customer&lt;/P&gt;&lt;P&gt;where Date&amp;gt;addmonths(today(),-26)&lt;/P&gt;&lt;P&gt;&amp;nbsp;Any suggestions why the Date field cannot be found?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2020 05:15:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Customer-loyalty-based-on-months-since-last-activity/m-p/1757235#M720535</guid>
      <dc:creator>QlikNewbie20</dc:creator>
      <dc:date>2020-10-30T05:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: Customer loyalty based on months since last activity</title>
      <link>https://community.qlik.com/t5/QlikView/Customer-loyalty-based-on-months-since-last-activity/m-p/1757236#M720536</link>
      <description>&lt;P&gt;Hi Martijn&lt;/P&gt;&lt;P&gt;Thanks for the quick reply. I'm curious to know where is the script does it reference the date field? The field that I use is called TransDate so I'm not sure where to insert that.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2020 05:19:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Customer-loyalty-based-on-months-since-last-activity/m-p/1757236#M720536</guid>
      <dc:creator>QlikNewbie20</dc:creator>
      <dc:date>2020-10-30T05:19:19Z</dc:date>
    </item>
    <item>
      <title>Re: Customer loyalty based on months since last activity</title>
      <link>https://community.qlik.com/t5/QlikView/Customer-loyalty-based-on-months-since-last-activity/m-p/1757345#M720538</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/126541"&gt;@QlikNewbie20&lt;/a&gt;&amp;nbsp; glad that martijn's code worked but please mark his answer as the solution not your own.&lt;/P&gt;&lt;P&gt;the whole point of this community is to give credit to people who help others with their time&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2020 13:39:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Customer-loyalty-based-on-months-since-last-activity/m-p/1757345#M720538</guid>
      <dc:creator>dplr-rn</dc:creator>
      <dc:date>2020-10-30T13:39:18Z</dc:date>
    </item>
    <item>
      <title>Re: Customer loyalty based on months since last activity</title>
      <link>https://community.qlik.com/t5/QlikView/Customer-loyalty-based-on-months-since-last-activity/m-p/1757379#M720539</link>
      <description>&lt;P&gt;Hi. Sorry, I clicked wrong button. Updated now. Thanks guys.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2020 15:11:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Customer-loyalty-based-on-months-since-last-activity/m-p/1757379#M720539</guid>
      <dc:creator>QlikNewbie20</dc:creator>
      <dc:date>2020-10-30T15:11:24Z</dc:date>
    </item>
  </channel>
</rss>

