<?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 Peek in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Peek/m-p/420083#M696620</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone advise me on what is wrong with this code/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff6600;"&gt;CustOrders:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff6600;"&gt;NoConcatenate&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff6600;"&gt;LOAD DISTINCT [Customer ID],[SalesOrderLine Number],[SalesOrderLine Date]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff6600;"&gt;RESIDENT SalesOrders&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff6600;"&gt;ORDER BY [Customer ID],[SalesOrderLine Date] ASC;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff6600;"&gt;LastOrders:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff6600;"&gt;NoConcatenate&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff6600;"&gt;LOAD [SalesOrderLine Number], IF(Peek('Customer ID')=[Customer ID],Peek('SalesOrderLine Date'),NULL()) As LastOrderDate&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff6600;"&gt;RESIDENT CustOrders&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff6600;"&gt;ORDER BY [Customer ID], [SalesOrderLine Date] ASC;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff6600;"&gt;DROP TABLE CustOrders;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to create a table 'Last Orders' that contains, for each 'SalesOrderLine Number', the date of the previous order placed by the customer (or Null if there was no previous order).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This script currently gives me a null value for every 'LastOrderDate'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Darren&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 02 May 2013 11:38:32 GMT</pubDate>
    <dc:creator>johnso2080</dc:creator>
    <dc:date>2013-05-02T11:38:32Z</dc:date>
    <item>
      <title>Peek</title>
      <link>https://community.qlik.com/t5/QlikView/Peek/m-p/420083#M696620</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone advise me on what is wrong with this code/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff6600;"&gt;CustOrders:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff6600;"&gt;NoConcatenate&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff6600;"&gt;LOAD DISTINCT [Customer ID],[SalesOrderLine Number],[SalesOrderLine Date]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff6600;"&gt;RESIDENT SalesOrders&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff6600;"&gt;ORDER BY [Customer ID],[SalesOrderLine Date] ASC;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff6600;"&gt;LastOrders:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff6600;"&gt;NoConcatenate&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff6600;"&gt;LOAD [SalesOrderLine Number], IF(Peek('Customer ID')=[Customer ID],Peek('SalesOrderLine Date'),NULL()) As LastOrderDate&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff6600;"&gt;RESIDENT CustOrders&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff6600;"&gt;ORDER BY [Customer ID], [SalesOrderLine Date] ASC;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff6600;"&gt;DROP TABLE CustOrders;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to create a table 'Last Orders' that contains, for each 'SalesOrderLine Number', the date of the previous order placed by the customer (or Null if there was no previous order).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This script currently gives me a null value for every 'LastOrderDate'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Darren&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 May 2013 11:38:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Peek/m-p/420083#M696620</guid>
      <dc:creator>johnso2080</dc:creator>
      <dc:date>2013-05-02T11:38:32Z</dc:date>
    </item>
    <item>
      <title>Re: Peek</title>
      <link>https://community.qlik.com/t5/QlikView/Peek/m-p/420084#M696621</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try using above :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;SPAN style="color: #ff6600;"&gt;LastOrders:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;SPAN style="color: #ff6600;"&gt;NoConcatenate&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;SPAN style="color: #ff6600;"&gt;LOAD [SalesOrderLine Number], &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;SPAN style="color: #ff6600;"&gt;if(above(&lt;SPAN style="color: #ff6600; font-family: Arial; background-color: #ffffff;"&gt;[Customer ID]&lt;/SPAN&gt;)=&lt;SPAN style="color: #ff6600; font-family: Arial; background-color: #ffffff;"&gt;[Customer ID]&lt;/SPAN&gt;, above(&lt;SPAN style="color: #ff6600; font-family: Arial; background-color: #ffffff;"&gt;[SalesOrderLine Date], null()&lt;/SPAN&gt;) As LastOrderDate&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;SPAN style="color: #ff6600;"&gt;RESIDENT CustOrders&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;SPAN style="color: #ff6600;"&gt;ORDER BY [Customer ID], [SalesOrderLine Date] ASC;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 May 2013 11:43:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Peek/m-p/420084#M696621</guid>
      <dc:creator>giakoum</dc:creator>
      <dc:date>2013-05-02T11:43:43Z</dc:date>
    </item>
    <item>
      <title>Re: Peek</title>
      <link>https://community.qlik.com/t5/QlikView/Peek/m-p/420085#M696622</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry not above (works only in charts), you need to use previous:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;SPAN style="color: #ff6600;"&gt;LastOrders:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;SPAN style="color: #ff6600;"&gt;NoConcatenate&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;SPAN style="color: #ff6600;"&gt;LOAD [SalesOrderLine Number],&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;SPAN style="color: #ff6600;"&gt;if(previous([Customer ID])=[Customer ID], previous([SalesOrderLine Date], null()) As LastOrderDate&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;SPAN style="color: #ff6600;"&gt;RESIDENT CustOrders&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;SPAN style="color: #ff6600;"&gt;ORDER BY [Customer ID], [SalesOrderLine Date] ASC;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 May 2013 11:45:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Peek/m-p/420085#M696622</guid>
      <dc:creator>giakoum</dc:creator>
      <dc:date>2013-05-02T11:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: Peek</title>
      <link>https://community.qlik.com/t5/QlikView/Peek/m-p/420086#M696623</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you need to use the previous() function here instead of peek().&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #737373; font-family: Arial; background-color: #ffffff;"&gt;IF(Previous([Customer ID])=[Customer ID],Previous([SalesOrderLine Date]),NULL()) As LastOrderDate&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 May 2013 11:48:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Peek/m-p/420086#M696623</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2013-05-02T11:48:50Z</dc:date>
    </item>
    <item>
      <title>Re: Peek</title>
      <link>https://community.qlik.com/t5/QlikView/Peek/m-p/420087#M696624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your help,&lt;/P&gt;&lt;P&gt;It's still not working using the 'Previous' function as below... Any other possibilities?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CustOrders:&lt;/P&gt;&lt;P&gt;NoConcatenate&lt;/P&gt;&lt;P&gt;LOAD DISTINCT [Customer ID],[SalesOrderLine Number],[SalesOrderLine Date]&lt;/P&gt;&lt;P&gt;RESIDENT SalesOrders&lt;/P&gt;&lt;P&gt;ORDER BY [Customer ID],[SalesOrderLine Date] ASC;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LastOrders:&lt;/P&gt;&lt;P&gt;NoConcatenate&lt;/P&gt;&lt;P&gt;LOAD [SalesOrderLine Number], IF(Previous('Customer ID')=[Customer ID],Previous('SalesOrderLine Date'),NULL()) As LastOrderDate&lt;/P&gt;&lt;P&gt;RESIDENT CustOrders&lt;/P&gt;&lt;P&gt;ORDER BY [Customer ID], [SalesOrderLine Date] ASC;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DROP TABLE CustOrders;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 May 2013 12:03:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Peek/m-p/420087#M696624</guid>
      <dc:creator>johnso2080</dc:creator>
      <dc:date>2013-05-02T12:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: Peek</title>
      <link>https://community.qlik.com/t5/QlikView/Peek/m-p/420088#M696625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;a sample application would help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 May 2013 12:09:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Peek/m-p/420088#M696625</guid>
      <dc:creator>giakoum</dc:creator>
      <dc:date>2013-05-02T12:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: Peek</title>
      <link>https://community.qlik.com/t5/QlikView/Peek/m-p/420089#M696626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can see several problems here...&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;If you sort Ascending, you will get the first order, not the last.&lt;/LI&gt;&lt;LI&gt;Peek does not work since you do not have [Customer ID] in the output. So Gysbert is right: Use Previous() instead.&lt;/LI&gt;&lt;LI&gt;You cannot use 'Customer ID' inside Previous(). You need to quote it with brackets or double quotes: [Customer ID]&lt;/LI&gt;&lt;LI&gt;The first record within a Customer ID gets NULL as LastOrderDate. But you want it to be a Date, don't you?&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bottom line, I would use&lt;/P&gt;&lt;P&gt;LOAD &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [SalesOrderLine Number], &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF(Previous([Customer ID])=[Customer ID],Peek([LastOrderDate]),[SalesOrderLine Date]) As LastOrderDate&lt;/P&gt;&lt;P&gt;RESIDENT CustOrders&lt;/P&gt;&lt;P&gt;ORDER BY [Customer ID], [SalesOrderLine Date] DESC;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HIC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 May 2013 15:09:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Peek/m-p/420089#M696626</guid>
      <dc:creator>hic</dc:creator>
      <dc:date>2013-05-02T15:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: Peek</title>
      <link>https://community.qlik.com/t5/QlikView/Peek/m-p/420090#M696627</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Henric! &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 May 2013 09:23:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Peek/m-p/420090#M696627</guid>
      <dc:creator>johnso2080</dc:creator>
      <dc:date>2013-05-08T09:23:41Z</dc:date>
    </item>
  </channel>
</rss>

