<?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: New/Lost/Returning/Loyal Customers in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/New-Lost-Returning-Loyal-Customers/m-p/981533#M335057</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this one then.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 25 Sep 2015 17:27:26 GMT</pubDate>
    <dc:creator>Gysbert_Wassenaar</dc:creator>
    <dc:date>2015-09-25T17:27:26Z</dc:date>
    <item>
      <title>New/Lost/Returning/Loyal Customers</title>
      <link>https://community.qlik.com/t5/QlikView/New-Lost-Returning-Loyal-Customers/m-p/981526#M335050</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm struggling to find a solution to count new/lost/returning/loyal customer over the years... I've tried different approaches posted on the community (script and expression), but couldn't reach what I want. I need it on expression! I'll neded to select years on a filter, use it on graphs...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Definitions: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;New - clients that never bought, and bought on the selected year.&lt;BR /&gt;Lost - clients that have bought last year, but not the selected year.&lt;/P&gt;&lt;P&gt;Returning - clients that have bought in any year before, didn't bought the previous year, but bought the selected year.&lt;/P&gt;&lt;P&gt;Loyal - clients that bought previous year, and the selected year.&lt;/P&gt;&lt;P&gt;The previous year is always compared to the selected year, not the actual year, like today...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The data (simplified):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ORDERID&lt;/P&gt;&lt;P&gt;CLIENTID&lt;/P&gt;&lt;P&gt;YEAR&lt;/P&gt;&lt;P&gt;SALESQTY&lt;/P&gt;&lt;P&gt;IDPRODUCTCATEGORY&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;(I cant open others apps)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Sep 2015 13:07:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/New-Lost-Returning-Loyal-Customers/m-p/981526#M335050</guid>
      <dc:creator>hvfalcao</dc:creator>
      <dc:date>2015-09-18T13:07:39Z</dc:date>
    </item>
    <item>
      <title>Re: New/Lost/Returning/Loyal Customers</title>
      <link>https://community.qlik.com/t5/QlikView/New-Lost-Returning-Loyal-Customers/m-p/981527#M335051</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try out some of the previous solutions to this question: &lt;A href="/t5/forums/searchpage/tab/message?q=new lost customers"&gt;https://community.qlik.com/search.jspa?q=new+lost+customers&lt;/A&gt;‌&lt;/P&gt;&lt;P&gt;If you need more help then post a small qlikview document with some realistic example data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Sep 2015 17:19:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/New-Lost-Returning-Loyal-Customers/m-p/981527#M335051</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2015-09-18T17:19:58Z</dc:date>
    </item>
    <item>
      <title>Re: New/Lost/Returning/Loyal Customers</title>
      <link>https://community.qlik.com/t5/QlikView/New-Lost-Returning-Loyal-Customers/m-p/981528#M335052</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Gysbert,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As I said above, I've already tried almost all solutions posted on the community...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm creating this app on Sense. I've posted on view, because there's more member to help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Follow the attachment... Its a table with Order Year and Count of Total Customers...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Sep 2015 18:10:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/New-Lost-Returning-Loyal-Customers/m-p/981528#M335052</guid>
      <dc:creator>hvfalcao</dc:creator>
      <dc:date>2015-09-18T18:10:52Z</dc:date>
    </item>
    <item>
      <title>Re: New/Lost/Returning/Loyal Customers</title>
      <link>https://community.qlik.com/t5/QlikView/New-Lost-Returning-Loyal-Customers/m-p/981529#M335053</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try these:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;New: count({&amp;lt;CLIENTID=E({&amp;lt;YYEAR={'&amp;lt;$(=max(YYEAR))'}&amp;gt;}CLIENTID)&amp;gt;} distinct CLIENTID)&lt;/P&gt;&lt;P&gt;Lost: count({&amp;lt;YYEAR={'$(=max(YYEAR)-1)'},CLIENTID=E({&amp;lt;YYEAR={'$(=max(YYEAR))'}&amp;gt;}CLIENTID)&amp;gt;} distinct CLIENTID)&lt;/P&gt;&lt;P&gt;Returning: count({&amp;lt;CLIENTID=P({&amp;lt;YYEAR={'&amp;lt;$(=max(YYEAR)-1)'}&amp;gt;}CLIENTID)&amp;gt;*&amp;lt;CLIENTID=E({&amp;lt;YYEAR={'$(=max(YYEAR)-1)'}&amp;gt;}CLIENTID)&amp;gt;} distinct CLIENTID)&lt;/P&gt;&lt;P&gt;Loyal: count({&amp;lt;YYEAR={'$(=max(YYEAR)-1)'},CLIENTID=P({&amp;lt;YYEAR={'$(=max(YYEAR))'}&amp;gt;}CLIENTID)&amp;gt;} distinct CLIENTID)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To be honest, this isn't really different from a lot of existing solutions. The field names are different, but the principle is the same. Use the P() and E() functions to select customers that do or don't have records in a certain period.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway, I hope these work for you. You can use them in Qlik Sense as well as Qlikview.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Sep 2015 07:45:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/New-Lost-Returning-Loyal-Customers/m-p/981529#M335053</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2015-09-19T07:45:12Z</dc:date>
    </item>
    <item>
      <title>Re: New/Lost/Returning/Loyal Customers</title>
      <link>https://community.qlik.com/t5/QlikView/New-Lost-Returning-Loyal-Customers/m-p/981530#M335054</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Gysbert,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've already tried that. It works if I select (filter) just one year, but if I select all years, or more than one, or use it on graphs, it won't work, because it'll show just the &lt;SPAN style="font-size: 13.3333px;"&gt;MAX(YYEAR) ... &lt;/SPAN&gt;&lt;IMG alt="Capturar1.JPG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/99546_Capturar1.JPG" style="height: 222px; width: 620px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've appreciated your help anyway... Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Sep 2015 14:39:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/New-Lost-Returning-Loyal-Customers/m-p/981530#M335054</guid>
      <dc:creator>hvfalcao</dc:creator>
      <dc:date>2015-09-21T14:39:55Z</dc:date>
    </item>
    <item>
      <title>Re: New/Lost/Returning/Loyal Customers</title>
      <link>https://community.qlik.com/t5/QlikView/New-Lost-Returning-Loyal-Customers/m-p/981531#M335055</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've tried to come up with a solution for that. I managed to create something that seems to be working.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Sep 2015 16:55:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/New-Lost-Returning-Loyal-Customers/m-p/981531#M335055</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2015-09-25T16:55:06Z</dc:date>
    </item>
    <item>
      <title>Re: New/Lost/Returning/Loyal Customers</title>
      <link>https://community.qlik.com/t5/QlikView/New-Lost-Returning-Loyal-Customers/m-p/981532#M335056</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Gysbert,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can't open .qvw from others... As I'm developing on Sense, I just have the free edition of QV... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you mind to post like your first answer? Thank you again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Sep 2015 17:14:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/New-Lost-Returning-Loyal-Customers/m-p/981532#M335056</guid>
      <dc:creator>hvfalcao</dc:creator>
      <dc:date>2015-09-25T17:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: New/Lost/Returning/Loyal Customers</title>
      <link>https://community.qlik.com/t5/QlikView/New-Lost-Returning-Loyal-Customers/m-p/981533#M335057</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this one then.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Sep 2015 17:27:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/New-Lost-Returning-Loyal-Customers/m-p/981533#M335057</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2015-09-25T17:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: New/Lost/Returning/Loyal Customers</title>
      <link>https://community.qlik.com/t5/QlikView/New-Lost-Returning-Loyal-Customers/m-p/981534#M335058</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/qlik-users/96544"&gt;gwassenaar&lt;/A&gt;‌ a nice solution but :&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Your code takes all the ClientId's and not only the ClientId's with sales&lt;/LI&gt;&lt;LI&gt;It's a little bit difficult to read/understand your code&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hereby the same solution but then with a less technical script. Your new table contains almost 48.000 rows, my solution only 1.318 rows. The outcome is identical but then easier with a better performance!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;YearsPerClient:&lt;/P&gt;&lt;P&gt;LOAD DISTINCT&lt;/P&gt;&lt;P&gt;&amp;nbsp; CLIENTID,&lt;/P&gt;&lt;P&gt;&amp;nbsp; FirstYearOfSales + ITERNO() - 1 AS SalesYear&lt;/P&gt;&lt;P&gt;WHILE FirstYearOfSales + ITERNO() - 1 &amp;lt;= IF(LastYearOfSales &amp;lt; YEAR(TODAY()), LastYearOfSales + 1, YEAR(TODAY()));&lt;/P&gt;&lt;P&gt;// &lt;SPAN style="font-size: 13.3333px;"&gt;LastYearOfSales &lt;/SPAN&gt; + 1 to count the lost clients!&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp; CLIENTID,&lt;/P&gt;&lt;P&gt;&amp;nbsp; MIN(YYEAR) AS FirstYearOfSales&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; MAX(YYEAR) AS LastYearOfSales&lt;/P&gt;&lt;P&gt;RESIDENT TABORDER&lt;/P&gt;&lt;P&gt;GROUP BY&lt;/P&gt;&lt;P&gt;&amp;nbsp; CLIENTID;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LEFT JOIN (YearsPerClient)&lt;/P&gt;&lt;P&gt;LOAD DISTINCT&lt;/P&gt;&lt;P&gt;&amp;nbsp; CLIENTID,&lt;/P&gt;&lt;P&gt;&amp;nbsp; YYEAR AS SalesYear,&lt;/P&gt;&lt;P&gt;&amp;nbsp; 1 AS SalesInYear&lt;/P&gt;&lt;P&gt;RESIDENT TABORDER;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ReturningNew:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp; CLIENTID,&lt;/P&gt;&lt;P&gt;&amp;nbsp; SalesYear,&lt;/P&gt;&lt;P&gt;&amp;nbsp; SalesInYear,&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF(CLIENTID = PREVIOUS(CLIENTID), NULL(), SalesInYear) AS isNewCustomer,&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF(CLIENTID = PREVIOUS(CLIENTID), IF(ALT(SalesInYear, 0) = 1 AND ALT(PREVIOUS(SalesInYear), 0) = 1, 1, NULL()), NULL()) AS isKeptCustomer,&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF(CLIENTID = PREVIOUS(CLIENTID), IF(ALT(SalesInYear, 0) = 1 AND ALT(PREVIOUS(SalesInYear), 0) &amp;lt;&amp;gt; 1, 1, NULL()), NULL()) AS isReturningCustomer,&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF(CLIENTID = PREVIOUS(CLIENTID), IF(ALT(SalesInYear, 0) &amp;lt;&amp;gt; 1 AND ALT(PREVIOUS(SalesInYear), 0) = 1, 1, NULL()), NULL()) AS isLostCustomer&lt;/P&gt;&lt;P&gt;RESIDENT YearsPerClient&lt;/P&gt;&lt;P&gt;ORDER BY&lt;/P&gt;&lt;P&gt;&amp;nbsp; CLIENTID,&lt;/P&gt;&lt;P&gt;&amp;nbsp; SalesYear;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DROP TABLE YearsPerClient;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 26 Sep 2015 09:47:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/New-Lost-Returning-Loyal-Customers/m-p/981534#M335058</guid>
      <dc:creator>gardenierbi</dc:creator>
      <dc:date>2015-09-26T09:47:50Z</dc:date>
    </item>
    <item>
      <title>Re: New/Lost/Returning/Loyal Customers</title>
      <link>https://community.qlik.com/t5/QlikView/New-Lost-Returning-Loyal-Customers/m-p/981535#M335059</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah, that's certainly an improvement. I was going to revise my solution since I wasn't satisfied with it yet and try to clean things up a but, but you beat me to it with a very nice solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Edit: I've cleaned things up a bit anyway. Cleaning out the unnecessary records is done easily enough, though I don't think it's really necessary. 48 thousand records is trivial for such a table and shouldn't cause any noticeable performance degradation.&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 26 Sep 2015 14:46:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/New-Lost-Returning-Loyal-Customers/m-p/981535#M335059</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2015-09-26T14:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: New/Lost/Returning/Loyal Customers</title>
      <link>https://community.qlik.com/t5/QlikView/New-Lost-Returning-Loyal-Customers/m-p/981536#M335060</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Very nice and clean solution! That was exactly what I need!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Thank you!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Sep 2015 14:57:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/New-Lost-Returning-Loyal-Customers/m-p/981536#M335060</guid>
      <dc:creator>hvfalcao</dc:creator>
      <dc:date>2015-09-28T14:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: New/Lost/Returning/Loyal Customers</title>
      <link>https://community.qlik.com/t5/QlikView/New-Lost-Returning-Loyal-Customers/m-p/981537#M335061</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is good stuf, if you want to measure the retirning customers by Monthyear instead of year you will just need to change thus customer history tab logic to Monthname?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Oct 2015 20:41:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/New-Lost-Returning-Loyal-Customers/m-p/981537#M335061</guid>
      <dc:creator>hectorgarcia</dc:creator>
      <dc:date>2015-10-08T20:41:07Z</dc:date>
    </item>
    <item>
      <title>Re: New/Lost/Returning/Loyal Customers</title>
      <link>https://community.qlik.com/t5/QlikView/New-Lost-Returning-Loyal-Customers/m-p/981538#M335062</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Basically yes. But MonthName values are dates, not sequential numbers like years. So you need to use the addmonths function instead of just adding integers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Oct 2015 09:36:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/New-Lost-Returning-Loyal-Customers/m-p/981538#M335062</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2015-10-09T09:36:38Z</dc:date>
    </item>
    <item>
      <title>Re: New/Lost/Returning/Loyal Customers</title>
      <link>https://community.qlik.com/t5/QlikView/New-Lost-Returning-Loyal-Customers/m-p/1749543#M453517</link>
      <description>&lt;P&gt;Thanks for this solution to a quite tricky problem! Worked great for my app too.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Oct 2020 10:03:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/New-Lost-Returning-Loyal-Customers/m-p/1749543#M453517</guid>
      <dc:creator>fluxfrog</dc:creator>
      <dc:date>2020-10-05T10:03:22Z</dc:date>
    </item>
  </channel>
</rss>

