<?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 Reading latest 4 files based on period in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Reading-latest-4-files-based-on-period/m-p/236012#M87235</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 am working on two scripts right now - (a) first one creates the QVD files (b) Second one reads the QVDs and creates a model for dashboard.&lt;/P&gt;&lt;P&gt;The dashboard should consider only last 4 months data. The issue here is the last 4 months can be like 201006, 201003, 201002, 201001. When creating in (a) I am using input fields to decide the period for which QVDs have to be created and then create QVDs for the period.&lt;/P&gt;&lt;P&gt;Let us say now I have now the QVDs for above months. When I run (a) in Aug 10, I would create files for 201007. The files available now are for 5 months. Then (b) should read only last 4 months i.e. 201007, 201006, 201003 and 201002.&lt;/P&gt;&lt;P&gt;I want achive this when I run (b) and last 4 months should be picked automatically based on available period QVD files.&lt;/P&gt;&lt;P&gt;I read something about Edit Module which allows one to do the VB Script. But as I have just started thought to check if this is the best way or some other options are also available.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 28 Jul 2010 06:39:35 GMT</pubDate>
    <dc:creator />
    <dc:date>2010-07-28T06:39:35Z</dc:date>
    <item>
      <title>Reading latest 4 files based on period</title>
      <link>https://community.qlik.com/t5/QlikView/Reading-latest-4-files-based-on-period/m-p/236012#M87235</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 am working on two scripts right now - (a) first one creates the QVD files (b) Second one reads the QVDs and creates a model for dashboard.&lt;/P&gt;&lt;P&gt;The dashboard should consider only last 4 months data. The issue here is the last 4 months can be like 201006, 201003, 201002, 201001. When creating in (a) I am using input fields to decide the period for which QVDs have to be created and then create QVDs for the period.&lt;/P&gt;&lt;P&gt;Let us say now I have now the QVDs for above months. When I run (a) in Aug 10, I would create files for 201007. The files available now are for 5 months. Then (b) should read only last 4 months i.e. 201007, 201006, 201003 and 201002.&lt;/P&gt;&lt;P&gt;I want achive this when I run (b) and last 4 months should be picked automatically based on available period QVD files.&lt;/P&gt;&lt;P&gt;I read something about Edit Module which allows one to do the VB Script. But as I have just started thought to check if this is the best way or some other options are also available.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Jul 2010 06:39:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Reading-latest-4-files-based-on-period/m-p/236012#M87235</guid>
      <dc:creator />
      <dc:date>2010-07-28T06:39:35Z</dc:date>
    </item>
    <item>
      <title>Reading latest 4 files based on period</title>
      <link>https://community.qlik.com/t5/QlikView/Reading-latest-4-files-based-on-period/m-p/236013#M87236</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 am not sure , but you can try for&lt;/P&gt;&lt;P&gt;=Date(addmonths(MonthStart(Max([Your Date])),-1),'MMYYYY') ,&lt;/P&gt;&lt;P&gt;Date(addmonths(MonthStart(Max([Your Date])),-2),'MMYYYY') and so on.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Manish Kumar&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Jul 2010 07:17:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Reading-latest-4-files-based-on-period/m-p/236013#M87236</guid>
      <dc:creator>manishkumar75</dc:creator>
      <dc:date>2010-07-28T07:17:57Z</dc:date>
    </item>
    <item>
      <title>Reading latest 4 files based on period</title>
      <link>https://community.qlik.com/t5/QlikView/Reading-latest-4-files-based-on-period/m-p/236014#M87237</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey there,&lt;/P&gt;&lt;P&gt;No need for macros. Easier to do this in the QlikView script. Here's an example I threw together. In your case it's easy since the more recent the QVD file, the larger the numerical value representing it. 201007 is larger than 201006 which is larger than 201003, so basically you want to pick the 4 largest QVD "numbers".&lt;/P&gt;&lt;P&gt;In this example I created a QVDFolder on C: and created 5 QVDs, 201007, 201006, 201005, 201003 &amp;amp; 201002.&lt;/P&gt;&lt;P&gt;The following script picks up all QVD-files from the folder in the top variable. Then it loads then in descending order so that 201007 ends up on top and loads the first 4 occurences, i.e. the first 4 month QVDs:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Let vQVD_Dir = 'C:\QVDFolder\';&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;for each Ext in 'qvd'&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;for each File in filelist ('$(vQVD_Dir)' &amp;amp; '*.' &amp;amp;Ext)&lt;BR /&gt; T1:&lt;BR /&gt; Load distinct&lt;BR /&gt; filename() as Name&lt;BR /&gt; from '$(File)';&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;next File&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;next Ext&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;NOCONCATENATE&lt;BR /&gt;LastFour:&lt;BR /&gt;First 4 Load&lt;BR /&gt; Name&lt;BR /&gt;resident T1&lt;BR /&gt;Order by Name desc;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Drop table T1;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Jul 2010 07:24:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Reading-latest-4-files-based-on-period/m-p/236014#M87237</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-07-28T07:24:36Z</dc:date>
    </item>
    <item>
      <title>Reading latest 4 files based on period</title>
      <link>https://community.qlik.com/t5/QlikView/Reading-latest-4-files-based-on-period/m-p/236015#M87238</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Johannes. It worked and I am able to get the last 4 files now.&lt;/P&gt;&lt;P&gt;I want to read them now one by one in single table. I tried with for loop but as &lt;EM&gt;Name&lt;/EM&gt; is now in the &lt;EM&gt;LastFour&lt;/EM&gt; table, I am not able to have it in loop.&lt;/P&gt;&lt;P&gt;Any suggestion for that?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jul 2010 08:36:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Reading-latest-4-files-based-on-period/m-p/236015#M87238</guid>
      <dc:creator />
      <dc:date>2010-07-29T08:36:08Z</dc:date>
    </item>
    <item>
      <title>Reading latest 4 files based on period</title>
      <link>https://community.qlik.com/t5/QlikView/Reading-latest-4-files-based-on-period/m-p/236016#M87239</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah,&lt;/P&gt;&lt;P&gt;Just apply the same principle and step through the 4 values in the &lt;EM&gt;Name&lt;/EM&gt; field like this:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;For a=0 to FieldValueCount('Name')-1&lt;BR /&gt; Let vFilename = Peek('Name',$(a),'LastFour');&lt;BR /&gt; Load&lt;BR /&gt; *&lt;BR /&gt; from '$(vFilename)' (qvd);&lt;BR /&gt;next&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;First I initiate a loop from 0-3, (FieldValueCount checks the number of values in the field Name). Then I pull the actual value into a variable, using Peek(). When using Peek, the first row is 0, hence the loop from 0-3 instead of 1-4. Then I use the variable, vFilename in the from statement in the QVD load. Hope it makes sense.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jul 2010 08:54:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Reading-latest-4-files-based-on-period/m-p/236016#M87239</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-07-29T08:54:09Z</dc:date>
    </item>
    <item>
      <title>Reading latest 4 files based on period</title>
      <link>https://community.qlik.com/t5/QlikView/Reading-latest-4-files-based-on-period/m-p/236017#M87240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot Johannes! It worked now. I was able to create working model from single period files. The only issue was making it to work automatically with last 4 periods. I have one QVD for each table from source for each period.&lt;/P&gt;&lt;P&gt;The major hurdle (according to me) was having the 4 part automated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jul 2010 09:25:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Reading-latest-4-files-based-on-period/m-p/236017#M87240</guid>
      <dc:creator />
      <dc:date>2010-07-29T09:25:27Z</dc:date>
    </item>
  </channel>
</rss>

