<?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 Script to define customer as new or old in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Script-to-define-customer-as-new-or-old/m-p/495860#M691235</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a problem I'm struggling to overcome, I have created a dashboard with around 10 tables all joined with no problem, the tables have customer information, transaction details, product descriptions and so on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to give each customer a flag of "new"&amp;nbsp; when they buy the first one of a range of products and use that date as the 1st first purchase and potentially a Flag of "Old" for future purchases.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The customer table has a created date, UniqueID.&lt;/P&gt;&lt;P&gt;The Transaction table is for a specific range of products which a customer may or may not have had.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to have this calculated in the load script and have in the past been successful with a simple if - and Im quite green with scripting so any help or a steer on where to try and find out the answer would be of great help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 30 Sep 2013 16:11:35 GMT</pubDate>
    <dc:creator>pauledrich</dc:creator>
    <dc:date>2013-09-30T16:11:35Z</dc:date>
    <item>
      <title>Script to define customer as new or old</title>
      <link>https://community.qlik.com/t5/QlikView/Script-to-define-customer-as-new-or-old/m-p/495860#M691235</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a problem I'm struggling to overcome, I have created a dashboard with around 10 tables all joined with no problem, the tables have customer information, transaction details, product descriptions and so on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to give each customer a flag of "new"&amp;nbsp; when they buy the first one of a range of products and use that date as the 1st first purchase and potentially a Flag of "Old" for future purchases.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The customer table has a created date, UniqueID.&lt;/P&gt;&lt;P&gt;The Transaction table is for a specific range of products which a customer may or may not have had.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to have this calculated in the load script and have in the past been successful with a simple if - and Im quite green with scripting so any help or a steer on where to try and find out the answer would be of great help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Sep 2013 16:11:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Script-to-define-customer-as-new-or-old/m-p/495860#M691235</guid>
      <dc:creator>pauledrich</dc:creator>
      <dc:date>2013-09-30T16:11:35Z</dc:date>
    </item>
    <item>
      <title>Re: Script to define customer as new or old</title>
      <link>https://community.qlik.com/t5/QlikView/Script-to-define-customer-as-new-or-old/m-p/495861#M691236</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Could you please load your script to make it easy for everyone to understand?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Sep 2013 16:53:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Script-to-define-customer-as-new-or-old/m-p/495861#M691236</guid>
      <dc:creator>MK_QSL</dc:creator>
      <dc:date>2013-09-30T16:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: Script to define customer as new or old</title>
      <link>https://community.qlik.com/t5/QlikView/Script-to-define-customer-as-new-or-old/m-p/495862#M691237</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Paul,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I'm assuming that the same customer is both "new" and "old", depending on time of purchase.&amp;nbsp; So, it makes sense to flag the purchase itself as "new" or "old" per customer per product.&amp;nbsp; The "Yes" value is assigned when a customer buys a product for the first time.&amp;nbsp; Example:&lt;BR /&gt;"Data" table includes CustomerId, ProductId, PurchaseId, and Date.&lt;BR /&gt;The script to could be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tmp:&lt;BR /&gt;LOAD DISTINCT&lt;BR /&gt; CustomerId, &lt;BR /&gt; ProductId, &lt;BR /&gt; min(Date) as FirstPurchaseDate // this is the date of the 1st purchase of Product by Customer&lt;BR /&gt;RESIDENT Data&lt;BR /&gt;GROUP BY CustomerId, ProductId;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LEFT JOIN (Data) LOAD DISTINCT&lt;BR /&gt; CustomerId, &lt;BR /&gt; ProductId, &lt;BR /&gt; FirstPurchaseDate&lt;BR /&gt;RESIDENT tmp;&lt;BR /&gt;DROP TABLE tmp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LEFT JOIN (Data) LOAD DISTINCT&lt;BR /&gt; PurchaseId,&lt;BR /&gt; CustomerId, &lt;BR /&gt; ProductId, &lt;BR /&gt; Date&lt;BR /&gt; if(FirstPurchaseDate=Date, 'Yes','No') as NewCustomer&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // this is your flag&lt;BR /&gt;RESIDENT tmp;&lt;BR /&gt;DROP FIELD FirstPurchaseDate;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Sep 2013 18:24:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Script-to-define-customer-as-new-or-old/m-p/495862#M691237</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-09-30T18:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: Script to define customer as new or old</title>
      <link>https://community.qlik.com/t5/QlikView/Script-to-define-customer-as-new-or-old/m-p/495863#M691238</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Michael&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for the reply &amp;amp; sorry for the late reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looks good and thanks for the help - I will be getting back to this piece of work later this week and will keep you updated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Oct 2013 11:02:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Script-to-define-customer-as-new-or-old/m-p/495863#M691238</guid>
      <dc:creator>pauledrich</dc:creator>
      <dc:date>2013-10-07T11:02:35Z</dc:date>
    </item>
    <item>
      <title>Re: Script to define customer as new or old</title>
      <link>https://community.qlik.com/t5/QlikView/Script-to-define-customer-as-new-or-old/m-p/495864#M691239</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Michael&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have added the solution to the load script with amendments to correct field names and receive error messages in order :-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Table not found&lt;/P&gt;&lt;P&gt;tmp:&lt;/P&gt;&lt;P&gt;LOAD DISTINCT&lt;/P&gt;&lt;P&gt; CustomerID, &lt;/P&gt;&lt;P&gt; ProductID, &lt;/P&gt;&lt;P&gt; min(AgreementDate) as FirstPurchaseDate &lt;/P&gt;&lt;P&gt;RESIDENT Data&lt;/P&gt;&lt;P&gt;GROUP BY CustomerID, ProductID&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2.&lt;/P&gt;&lt;P&gt;Table not found&lt;/P&gt;&lt;P&gt;LEFT JOIN (Data) LOAD DISTINCT&lt;/P&gt;&lt;P&gt; CustomerID, &lt;/P&gt;&lt;P&gt; ProductID, &lt;/P&gt;&lt;P&gt; FirstPurchaseDate&lt;/P&gt;&lt;P&gt;RESIDENT tmp&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3.&lt;/P&gt;&lt;P&gt;Table not found&lt;/P&gt;&lt;P&gt;DROP TABLES statement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4.&lt;/P&gt;&lt;P&gt;Table not found&lt;BR /&gt;LEFT JOIN (Data) LOAD DISTINCT&lt;BR /&gt; AgreementID,&lt;BR /&gt; CustomerID, &lt;BR /&gt; ProductID, &lt;BR /&gt; AgreementDate,&lt;BR /&gt; if(FirstPurchaseDate=AgreementDate, 'Yes','No') as NewCustomer&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;RESIDENT tmp&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;5.&lt;/P&gt;&lt;P&gt;Field not found&lt;/P&gt;&lt;P&gt;Did not find the field "FirstPurchaseDate" from the DROP FIELD statement&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Oct 2013 13:54:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Script-to-define-customer-as-new-or-old/m-p/495864#M691239</guid>
      <dc:creator>pauledrich</dc:creator>
      <dc:date>2013-10-14T13:54:03Z</dc:date>
    </item>
    <item>
      <title>Re: Script to define customer as new or old</title>
      <link>https://community.qlik.com/t5/QlikView/Script-to-define-customer-as-new-or-old/m-p/495865#M691240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Paul,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first error message means that there is no table "Data".&amp;nbsp; You need to use the real name of the table.&amp;nbsp; Notice that in my example it is not only in LOAD RESIDENT, but also in JOIN (Data) LOAD.&lt;/P&gt;&lt;P&gt;All other errors are the results of the first one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Oct 2013 14:26:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Script-to-define-customer-as-new-or-old/m-p/495865#M691240</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-10-14T14:26:13Z</dc:date>
    </item>
    <item>
      <title>Re: Script to define customer as new or old</title>
      <link>https://community.qlik.com/t5/QlikView/Script-to-define-customer-as-new-or-old/m-p/495866#M691241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Michael&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have made the change and included the table name where there is "Data" and still receive the same error messages?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Oct 2013 09:06:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Script-to-define-customer-as-new-or-old/m-p/495866#M691241</guid>
      <dc:creator>pauledrich</dc:creator>
      <dc:date>2013-10-18T09:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: Script to define customer as new or old</title>
      <link>https://community.qlik.com/t5/QlikView/Script-to-define-customer-as-new-or-old/m-p/495867#M691242</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you send the log file or the qvw itself?&amp;nbsp; Or the script as text?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Oct 2013 15:18:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Script-to-define-customer-as-new-or-old/m-p/495867#M691242</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-10-18T15:18:08Z</dc:date>
    </item>
  </channel>
</rss>

