<?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 Loading latest file in folder in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Loading-latest-file-in-folder/m-p/233698#M85228</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have Oracle reports that are saved once a day on a local FTP server. I need to load the latest report based on the date the report was printed. I have written the following load statement;&lt;/P&gt;&lt;P&gt;sub readWIP(root)&lt;BR /&gt;for each File in filelist(root &amp;amp; '\*.txt')&lt;BR /&gt; tmpWIP:&lt;BR /&gt; LOAD @1:45 as wo_key,&lt;BR /&gt; if(@1:5='Date:',@13:21,peek('tmpReportDate')) as tmpReportDate,&lt;BR /&gt; @1:45 as tmpWO,&lt;BR /&gt; @242:260 as tmpStatus&lt;BR /&gt; FROM [$(File)] (fix, codepage is 1252, header is 1 lines);&lt;BR /&gt;next File&lt;BR /&gt;end sub&lt;BR /&gt;&lt;BR /&gt;call readWIP('\\oer1euappw01\ftproot\reports\Discrete_Job_Value');&lt;BR /&gt;&lt;BR /&gt;WIP:&lt;BR /&gt;Load wo_key,&lt;BR /&gt; tmpReportDate,&lt;BR /&gt; tmpWO,&lt;BR /&gt; tmpStatus&lt;BR /&gt;RESIDENT tmpWIP&lt;BR /&gt;WHERE tmpStatus = 'Released' and &lt;B&gt;tmpReportDate = LATEST&lt;/B&gt;;&lt;BR /&gt;&lt;BR /&gt;drop table tmpWIP;&lt;/P&gt;&lt;P&gt;---&lt;/P&gt;&lt;P&gt;Any ideas on how to write the &lt;B&gt;code in bold&lt;/B&gt; or am I going about this entirely wrong?&lt;/P&gt;&lt;P&gt;Best Regards,&lt;BR /&gt;Jonas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 11 Oct 2010 14:04:30 GMT</pubDate>
    <dc:creator />
    <dc:date>2010-10-11T14:04:30Z</dc:date>
    <item>
      <title>Loading latest file in folder</title>
      <link>https://community.qlik.com/t5/QlikView/Loading-latest-file-in-folder/m-p/233698#M85228</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have Oracle reports that are saved once a day on a local FTP server. I need to load the latest report based on the date the report was printed. I have written the following load statement;&lt;/P&gt;&lt;P&gt;sub readWIP(root)&lt;BR /&gt;for each File in filelist(root &amp;amp; '\*.txt')&lt;BR /&gt; tmpWIP:&lt;BR /&gt; LOAD @1:45 as wo_key,&lt;BR /&gt; if(@1:5='Date:',@13:21,peek('tmpReportDate')) as tmpReportDate,&lt;BR /&gt; @1:45 as tmpWO,&lt;BR /&gt; @242:260 as tmpStatus&lt;BR /&gt; FROM [$(File)] (fix, codepage is 1252, header is 1 lines);&lt;BR /&gt;next File&lt;BR /&gt;end sub&lt;BR /&gt;&lt;BR /&gt;call readWIP('\\oer1euappw01\ftproot\reports\Discrete_Job_Value');&lt;BR /&gt;&lt;BR /&gt;WIP:&lt;BR /&gt;Load wo_key,&lt;BR /&gt; tmpReportDate,&lt;BR /&gt; tmpWO,&lt;BR /&gt; tmpStatus&lt;BR /&gt;RESIDENT tmpWIP&lt;BR /&gt;WHERE tmpStatus = 'Released' and &lt;B&gt;tmpReportDate = LATEST&lt;/B&gt;;&lt;BR /&gt;&lt;BR /&gt;drop table tmpWIP;&lt;/P&gt;&lt;P&gt;---&lt;/P&gt;&lt;P&gt;Any ideas on how to write the &lt;B&gt;code in bold&lt;/B&gt; or am I going about this entirely wrong?&lt;/P&gt;&lt;P&gt;Best Regards,&lt;BR /&gt;Jonas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Oct 2010 14:04:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loading-latest-file-in-folder/m-p/233698#M85228</guid>
      <dc:creator />
      <dc:date>2010-10-11T14:04:30Z</dc:date>
    </item>
    <item>
      <title>Loading latest file in folder</title>
      <link>https://community.qlik.com/t5/QlikView/Loading-latest-file-in-folder/m-p/233699#M85229</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You should include the filename in the tmpWIP, then create a table with the filename and the latest date, take this into a variable and load this file.&lt;BR /&gt;Script might look:&lt;BR /&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;sub readWIP(root)&lt;BR /&gt;for each File in filelist(root &amp;amp; '\*.txt')&lt;BR /&gt; tmpWIP:&lt;BR /&gt; LOAD @1:45 as wo_key,&lt;BR /&gt; if(@1:5='Date:',@13:21,peek('tmpReportDate')) as tmpReportDate,&lt;BR /&gt; @1:45 as tmpWO, @242:260 as tmpStatus,&lt;BR /&gt;FILENAME() AS FileName,&lt;BR /&gt;FILETIME() AS FileTime&lt;BR /&gt; FROM [$(File)] (fix, codepage is 1252, header is 1 lines);&lt;BR /&gt;next File&lt;BR /&gt;end sub&lt;BR /&gt;&lt;BR /&gt;call readWIP('\\oer1euappw01\ftproot\reports\Discrete_Job_Value');&lt;BR /&gt;xLastFile:&lt;BR /&gt;LOAD&lt;BR /&gt;FIRSTSORTEDVALUE(FileName, -FileTime) AS LastFile&lt;BR /&gt;RESIDENT&lt;BR /&gt;tmpWIP&lt;BR /&gt;GROUP BY&lt;BR /&gt;FileName;&lt;BR /&gt;LET sLastFile = PEEK('LastFile, 0, 'xLastFile');&lt;BR /&gt;LOAD * FROM $(sLastFile);&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Alternatively you may also sort the tmpWIP by the date in descending order and pick with the PEEK-command the first filename in the first record&lt;/P&gt;&lt;P&gt;HTH&lt;BR /&gt;Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Oct 2010 20:38:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loading-latest-file-in-folder/m-p/233699#M85229</guid>
      <dc:creator>prieper</dc:creator>
      <dc:date>2010-10-11T20:38:58Z</dc:date>
    </item>
  </channel>
</rss>

