<?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 A better script design in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/A-better-script-design/m-p/142912#M22288</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello every body.&lt;/P&gt;&lt;P style="line-height: 12pt;"&gt;I need to read a table with invoice's data , and qualify the customer as "New" or "Old" if he has any invoice during the previous year. "If the customer of the invoice has any invoice related in the previous year (from the invoice date) is an OLD customer, if not, is a new customer"&lt;/P&gt;&lt;P style="line-height: 12pt;"&gt;I've tried to work with the following script, counting the number of invoices for customer, but I thinks that there must be an easy way&lt;/P&gt;&lt;P&gt;Sales1:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;InvoiceNumber,&lt;/P&gt;&lt;P&gt;InvoiceDate,&lt;/P&gt;&lt;P&gt;Customer&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FROM Sales.dbf;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LEFT JOIN&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;Customer,&lt;/P&gt;&lt;P&gt;InvoiceDate as Date2,&lt;/P&gt;&lt;P&gt;InvoiceNumber as InvoiceNumber2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FROM Sales.dbf;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;InvoiceNumber,&lt;/P&gt;&lt;P&gt;InvoiceDate,&lt;/P&gt;&lt;P&gt;Customer,&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;count(InvoiceNuber2)&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHERE Date2&amp;lt;=InvoiceDate and Date2&amp;gt;Invoicedate-365&lt;/P&gt;&lt;P&gt;GROUP BY InvoiceNumber, InvoiceDate, Customer;&lt;/P&gt;&lt;P&gt;Can anybody help me?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Apr 2009 05:40:21 GMT</pubDate>
    <dc:creator />
    <dc:date>2009-04-30T05:40:21Z</dc:date>
    <item>
      <title>A better script design</title>
      <link>https://community.qlik.com/t5/QlikView/A-better-script-design/m-p/142912#M22288</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello every body.&lt;/P&gt;&lt;P style="line-height: 12pt;"&gt;I need to read a table with invoice's data , and qualify the customer as "New" or "Old" if he has any invoice during the previous year. "If the customer of the invoice has any invoice related in the previous year (from the invoice date) is an OLD customer, if not, is a new customer"&lt;/P&gt;&lt;P style="line-height: 12pt;"&gt;I've tried to work with the following script, counting the number of invoices for customer, but I thinks that there must be an easy way&lt;/P&gt;&lt;P&gt;Sales1:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;InvoiceNumber,&lt;/P&gt;&lt;P&gt;InvoiceDate,&lt;/P&gt;&lt;P&gt;Customer&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FROM Sales.dbf;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LEFT JOIN&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;Customer,&lt;/P&gt;&lt;P&gt;InvoiceDate as Date2,&lt;/P&gt;&lt;P&gt;InvoiceNumber as InvoiceNumber2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FROM Sales.dbf;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;InvoiceNumber,&lt;/P&gt;&lt;P&gt;InvoiceDate,&lt;/P&gt;&lt;P&gt;Customer,&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;count(InvoiceNuber2)&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHERE Date2&amp;lt;=InvoiceDate and Date2&amp;gt;Invoicedate-365&lt;/P&gt;&lt;P&gt;GROUP BY InvoiceNumber, InvoiceDate, Customer;&lt;/P&gt;&lt;P&gt;Can anybody help me?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Apr 2009 05:40:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/A-better-script-design/m-p/142912#M22288</guid>
      <dc:creator />
      <dc:date>2009-04-30T05:40:21Z</dc:date>
    </item>
    <item>
      <title>A better script design</title>
      <link>https://community.qlik.com/t5/QlikView/A-better-script-design/m-p/142913#M22289</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't see how it meets the requirement "If the customer of the invoice has any invoice related in the previous year (from the invoice date) is an OLD customer, if not, is a new customer"...&lt;BR /&gt;Here is how I understand it from your description:&lt;BR /&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&lt;BR /&gt;Sales1:&lt;BR /&gt;LOAD&lt;BR /&gt; InvoiceNumber,&lt;BR /&gt; InvoiceDate,&lt;BR /&gt; Customer&lt;BR /&gt;FROM Sales.dbf;&lt;BR /&gt;JOIN (Sales1) LOAD DISTINCT&lt;BR /&gt; Customer,&lt;BR /&gt; Customer as OldCustomer,&lt;BR /&gt; 'Old' as "Old/New"&lt;BR /&gt;RESIDENT Sales1&lt;BR /&gt;// Only one of the following two "WHERE" lines must be used, depending on the requirements:&lt;BR /&gt;WHERE year(InvoiceDate) = year(today())-1; // has invoices in last year&lt;BR /&gt;WHERE InvoiceDate &amp;lt; AddMonths(today(), -12) ; // has invoices older than year&lt;BR /&gt;JOIN (Sales1) LOAD DISTINCT&lt;BR /&gt; Customer,&lt;BR /&gt; 'New' as "Old/New"&lt;BR /&gt;WHERE not exists(OldCustomer. Customer); // All customers who are not old&lt;BR /&gt;DROP FIELD OldCustomer;&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;As for the counting, it's probably better to do on the front end in this case. &lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Regards,&lt;BR /&gt;Michael&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Apr 2009 07:30:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/A-better-script-design/m-p/142913#M22289</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-04-30T07:30:21Z</dc:date>
    </item>
    <item>
      <title>A better script design</title>
      <link>https://community.qlik.com/t5/QlikView/A-better-script-design/m-p/142914#M22290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Michael,&lt;/P&gt;&lt;P&gt;Thats exactly what I was looking for.&lt;/P&gt;&lt;P&gt;Regards&lt;BR /&gt;Marcelo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 May 2009 01:46:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/A-better-script-design/m-p/142914#M22290</guid>
      <dc:creator />
      <dc:date>2009-05-01T01:46:20Z</dc:date>
    </item>
  </channel>
</rss>

