<?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: how to Load only the latest files? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/how-to-Load-only-the-latest-files/m-p/389037#M696946</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It could be something like this (please test, I can miss/mistype):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Files_src:&lt;BR /&gt;LOAD FileName() as File&amp;nbsp; &lt;BR /&gt;FROM [*.xlsx] (ooxml, explicit labels, table is [Sheet1]);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;File:&lt;BR /&gt;LOAD DISTINCT&lt;BR /&gt; File,&lt;BR /&gt; subfield(File, '_', 1) as FileDate&lt;BR /&gt;RESIDENT Files_src&lt;BR /&gt;DROP TABLE Files_src;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LatestFiles:&lt;BR /&gt;FIRST 2&lt;BR /&gt;LOAD DISTINCT&lt;BR /&gt; File as LatestTwoFiles&lt;BR /&gt;RESIDENT File&lt;BR /&gt;ORDER BY FileDate DESC;&lt;BR /&gt;DROP TABLE File;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET LatestFile1 = peek('LatestFile',0,'LatestFiles');&lt;BR /&gt;LET LatestFile2 = peek('LatestFile',1,'LatestFiles');&lt;BR /&gt;DROP TABLE LatestFile;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//-------------------------------&lt;/P&gt;&lt;P&gt;Data:&lt;BR /&gt;LOAD&lt;BR /&gt;...&lt;BR /&gt;RESIDENT FROM [$(LatestFile1).xlsx] (ooxml, explicit labels, table is [Sheet1]);&lt;BR /&gt;LOAD&lt;BR /&gt;...&lt;BR /&gt;RESIDENT FROM [$(LatestFile2).xlsx] (ooxml, explicit labels, table is [Sheet1]);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Michael&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit: In fact, I used this approach recently, except I needed only one latest file.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 25 Mar 2013 15:01:00 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2013-03-25T15:01:00Z</dc:date>
    <item>
      <title>how to Load only the latest files?</title>
      <link>https://community.qlik.com/t5/QlikView/how-to-Load-only-the-latest-files/m-p/389036#M696945</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i need some help for the following.&lt;/P&gt;&lt;P&gt;i recieve data as excel sheets on monthly basis that have name in the followong format.&lt;/P&gt;&lt;P&gt;YYYYMMDD_data.xls&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now all these files are saved in a specific folder. While loading the data i want to load the latest 2 files. e.g. if i have the following files &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;20130301_data.xls&lt;/P&gt;&lt;P&gt;20130201_data.xls&lt;/P&gt;&lt;P&gt;20130101_data.xls.&lt;/P&gt;&lt;P&gt;20121201_data,xls&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;than only the 20130301_data.xls and 20130201_data.xls should be loaded?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Mar 2013 14:42:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/how-to-Load-only-the-latest-files/m-p/389036#M696945</guid>
      <dc:creator>Vidit</dc:creator>
      <dc:date>2013-03-25T14:42:36Z</dc:date>
    </item>
    <item>
      <title>Re: how to Load only the latest files?</title>
      <link>https://community.qlik.com/t5/QlikView/how-to-Load-only-the-latest-files/m-p/389037#M696946</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It could be something like this (please test, I can miss/mistype):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Files_src:&lt;BR /&gt;LOAD FileName() as File&amp;nbsp; &lt;BR /&gt;FROM [*.xlsx] (ooxml, explicit labels, table is [Sheet1]);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;File:&lt;BR /&gt;LOAD DISTINCT&lt;BR /&gt; File,&lt;BR /&gt; subfield(File, '_', 1) as FileDate&lt;BR /&gt;RESIDENT Files_src&lt;BR /&gt;DROP TABLE Files_src;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LatestFiles:&lt;BR /&gt;FIRST 2&lt;BR /&gt;LOAD DISTINCT&lt;BR /&gt; File as LatestTwoFiles&lt;BR /&gt;RESIDENT File&lt;BR /&gt;ORDER BY FileDate DESC;&lt;BR /&gt;DROP TABLE File;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET LatestFile1 = peek('LatestFile',0,'LatestFiles');&lt;BR /&gt;LET LatestFile2 = peek('LatestFile',1,'LatestFiles');&lt;BR /&gt;DROP TABLE LatestFile;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//-------------------------------&lt;/P&gt;&lt;P&gt;Data:&lt;BR /&gt;LOAD&lt;BR /&gt;...&lt;BR /&gt;RESIDENT FROM [$(LatestFile1).xlsx] (ooxml, explicit labels, table is [Sheet1]);&lt;BR /&gt;LOAD&lt;BR /&gt;...&lt;BR /&gt;RESIDENT FROM [$(LatestFile2).xlsx] (ooxml, explicit labels, table is [Sheet1]);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Michael&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit: In fact, I used this approach recently, except I needed only one latest file.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Mar 2013 15:01:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/how-to-Load-only-the-latest-files/m-p/389037#M696946</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-03-25T15:01:00Z</dc:date>
    </item>
    <item>
      <title>Re: how to Load only the latest files?</title>
      <link>https://community.qlik.com/t5/QlikView/how-to-Load-only-the-latest-files/m-p/389038#M696947</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looks Good Michael. i will try this&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Mar 2013 15:03:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/how-to-Load-only-the-latest-files/m-p/389038#M696947</guid>
      <dc:creator>Vidit</dc:creator>
      <dc:date>2013-03-25T15:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: how to Load only the latest files?</title>
      <link>https://community.qlik.com/t5/QlikView/how-to-Load-only-the-latest-files/m-p/389039#M696948</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this. Copy and paste into test qvw application and set folder reference accordingly. Attached in text file also for reference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13642282920034844" jivemacro_uid="_13642282920034844"&gt;&lt;P&gt;set folder = "E:"&amp;nbsp;&amp;nbsp;&amp;nbsp; // set the folder to the desired file location - leave off everything following \filename.file-extension&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;for each file in filelist('$(folder)\*.xlsx')&lt;/P&gt;&lt;P&gt;FileInfo:&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;Distinct&lt;/P&gt;&lt;P&gt;FileName() as file_name,&lt;/P&gt;&lt;P&gt;FileBaseName() as file_base_name,&lt;/P&gt;&lt;P&gt;FilePath() as file_path,&lt;/P&gt;&lt;P&gt;FileTime() as file_time&lt;/P&gt;&lt;P&gt;from &lt;/P&gt;&lt;P&gt;$(file)&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;"&gt;(ooxml, embedded labels, table is Sheet1)&amp;nbsp;&amp;nbsp;&amp;nbsp; // change if needed for different table file format&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;;&lt;BR /&gt;next file&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;Qualify *&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;LatestFiles:&lt;/P&gt;&lt;P&gt;First(2)&amp;nbsp; // set this number to the number of recent files that you want to load&lt;/P&gt;&lt;P&gt;Load *&lt;/P&gt;&lt;P&gt;resident FileInfo&lt;/P&gt;&lt;P&gt;order by file_time DESC&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;Drop Table FileInfo&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;UNQUALIFY *&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;Let source = fieldname(3, 'LatestFiles')&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;Let source_i = fieldvalue('$(source)',1)&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;For i = 1 to NoofRows('LatestFiles')&lt;/P&gt;&lt;P&gt;[File$(i)]:&lt;/P&gt;&lt;P&gt;Load *,&lt;/P&gt;&lt;P&gt;'$(source_i)' as $(source)&lt;/P&gt;&lt;P&gt;from &lt;/P&gt;&lt;P&gt;$(source_i)&lt;/P&gt;&lt;P&gt;(ooxml, embedded labels, table is Sheet1)&amp;nbsp;&amp;nbsp;&amp;nbsp; // change if needed for different table file format&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Let source_i = fieldvalue('$(source)',$(i)+1)&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;next i&lt;/P&gt;&lt;P&gt;exit script&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Mar 2013 16:16:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/how-to-Load-only-the-latest-files/m-p/389039#M696948</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-03-25T16:16:00Z</dc:date>
    </item>
  </channel>
</rss>

