<?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 Looping to generate QVD in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Looping-to-generate-QVD/m-p/1744931#M57152</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have 2 months daily data and need to store previous 3 day data as current day qvd.&lt;/P&gt;&lt;P&gt;Below is my script. I'm able to generate the 3 day to one qvd file but I want to automate the qvd generation if I have like 2 or 1 month data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is my script. But the problem with this script is it keep generate the 1st sept 2020 qvd. I think its because of the minDate variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LET vMinDate = makedate(2020,09,01);&lt;BR /&gt;LET vMaxDate = makedate(2020,09,17);&lt;/P&gt;&lt;P&gt;FOR vCounter = '$(vMinDate)' to '$(vMaxDate)'&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;// LET vStartDate =addmonths(Today()-3,0); //ori script&lt;BR /&gt;// LET vToday =addmonths(Today()-1,0); //ori scritp&lt;/P&gt;&lt;P&gt;LET vStartDate =addmonths('$(vMinDate)'-3,0); //ori script&lt;BR /&gt;LET vToday =addmonths('$(vMinDate)'-1,0);&lt;/P&gt;&lt;P&gt;FOR vCounter = '$(vStartDate)' to '$(vToday)'; //loop the file date&lt;/P&gt;&lt;P&gt;LET vFilter = date('$(vCounter)','YYYYMMDD');&lt;/P&gt;&lt;P&gt;Inv_Period:&lt;BR /&gt;LOAD&lt;BR /&gt;Sales_Date as Inv_Date,&lt;BR /&gt;"Item No",&lt;BR /&gt;Outlet,&lt;BR /&gt;Total_BaseQty,&lt;BR /&gt;Total_Amount_Excl_Tax&lt;BR /&gt;FROM [lib://Data/T3/POS Detail/T3_POS_Detail_Daily_$(vFilter).qvd]&lt;BR /&gt;(qvd);&lt;/P&gt;&lt;P&gt;Next vCounter;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let vDate = Date(floor(NUM('$(vMinDate)')),'YYYYMMDD');&lt;BR /&gt;// LET vFilter2 = date('$(vCounter)','YYYYMMDD');&lt;BR /&gt;Inv:&lt;BR /&gt;Load&lt;BR /&gt;*,&lt;BR /&gt;Date(floor(NUM('$(vMinDate)')),'DD/MM/YYYY') as Sales_Date;&lt;BR /&gt;&lt;BR /&gt;LOAD&lt;BR /&gt;"Item No",&lt;BR /&gt;Outlet,&lt;BR /&gt;Sum(Total_BaseQty) as Sales_Qty,&lt;BR /&gt;Sum(Total_Amount_Excl_Tax) as Sales_Amt&lt;BR /&gt;Resident Inv_Period&lt;BR /&gt;Group by "Item No", Outlet;&lt;/P&gt;&lt;P&gt;Store Inv into [lib://Data/T3/Inventory Period/Test/T3_Inventory_Period_$(vDate).qvd](qvd);&lt;/P&gt;&lt;P&gt;Drop Table Inv;&lt;/P&gt;&lt;P&gt;next;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 18 Sep 2020 03:54:41 GMT</pubDate>
    <dc:creator>Hann</dc:creator>
    <dc:date>2020-09-18T03:54:41Z</dc:date>
    <item>
      <title>Looping to generate QVD</title>
      <link>https://community.qlik.com/t5/App-Development/Looping-to-generate-QVD/m-p/1744931#M57152</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have 2 months daily data and need to store previous 3 day data as current day qvd.&lt;/P&gt;&lt;P&gt;Below is my script. I'm able to generate the 3 day to one qvd file but I want to automate the qvd generation if I have like 2 or 1 month data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is my script. But the problem with this script is it keep generate the 1st sept 2020 qvd. I think its because of the minDate variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LET vMinDate = makedate(2020,09,01);&lt;BR /&gt;LET vMaxDate = makedate(2020,09,17);&lt;/P&gt;&lt;P&gt;FOR vCounter = '$(vMinDate)' to '$(vMaxDate)'&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;// LET vStartDate =addmonths(Today()-3,0); //ori script&lt;BR /&gt;// LET vToday =addmonths(Today()-1,0); //ori scritp&lt;/P&gt;&lt;P&gt;LET vStartDate =addmonths('$(vMinDate)'-3,0); //ori script&lt;BR /&gt;LET vToday =addmonths('$(vMinDate)'-1,0);&lt;/P&gt;&lt;P&gt;FOR vCounter = '$(vStartDate)' to '$(vToday)'; //loop the file date&lt;/P&gt;&lt;P&gt;LET vFilter = date('$(vCounter)','YYYYMMDD');&lt;/P&gt;&lt;P&gt;Inv_Period:&lt;BR /&gt;LOAD&lt;BR /&gt;Sales_Date as Inv_Date,&lt;BR /&gt;"Item No",&lt;BR /&gt;Outlet,&lt;BR /&gt;Total_BaseQty,&lt;BR /&gt;Total_Amount_Excl_Tax&lt;BR /&gt;FROM [lib://Data/T3/POS Detail/T3_POS_Detail_Daily_$(vFilter).qvd]&lt;BR /&gt;(qvd);&lt;/P&gt;&lt;P&gt;Next vCounter;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let vDate = Date(floor(NUM('$(vMinDate)')),'YYYYMMDD');&lt;BR /&gt;// LET vFilter2 = date('$(vCounter)','YYYYMMDD');&lt;BR /&gt;Inv:&lt;BR /&gt;Load&lt;BR /&gt;*,&lt;BR /&gt;Date(floor(NUM('$(vMinDate)')),'DD/MM/YYYY') as Sales_Date;&lt;BR /&gt;&lt;BR /&gt;LOAD&lt;BR /&gt;"Item No",&lt;BR /&gt;Outlet,&lt;BR /&gt;Sum(Total_BaseQty) as Sales_Qty,&lt;BR /&gt;Sum(Total_Amount_Excl_Tax) as Sales_Amt&lt;BR /&gt;Resident Inv_Period&lt;BR /&gt;Group by "Item No", Outlet;&lt;/P&gt;&lt;P&gt;Store Inv into [lib://Data/T3/Inventory Period/Test/T3_Inventory_Period_$(vDate).qvd](qvd);&lt;/P&gt;&lt;P&gt;Drop Table Inv;&lt;/P&gt;&lt;P&gt;next;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2020 03:54:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Looping-to-generate-QVD/m-p/1744931#M57152</guid>
      <dc:creator>Hann</dc:creator>
      <dc:date>2020-09-18T03:54:41Z</dc:date>
    </item>
    <item>
      <title>Re: Looping to generate QVD</title>
      <link>https://community.qlik.com/t5/App-Development/Looping-to-generate-QVD/m-p/1746185#M57292</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/69337"&gt;@Hann&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think adding some TRACE statements to the code might certainly help things out here.&lt;/P&gt;&lt;P&gt;I'm surprised that the FOR loops work on string dates, but then I have never tried this, so if the TRACE shows this is behaving as you require then great! I personally would get the dates as integers (e.g. 43653) and use those everywhere (except in the file suffixes).&lt;/P&gt;&lt;P&gt;Your outer loop is putting the date value in a variable called vCounter, but when you set vStartDate and vToday you are getting this from vMinDate, instead of vCounter. This is, I think, why you are always getting the same data in each itteration of the loop.&lt;/P&gt;&lt;P&gt;Also, I think you need to be dropping Inv_Period after you create the Inv table each time, or the Inv_Period table will simply keep growing.&lt;/P&gt;&lt;P&gt;Hopefully that will, at least, move you a bit nearer to the solution you are after.&lt;/P&gt;&lt;P&gt;Cheers,&lt;BR /&gt;Steve&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2020 21:09:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Looping-to-generate-QVD/m-p/1746185#M57292</guid>
      <dc:creator>stevedark</dc:creator>
      <dc:date>2020-09-22T21:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: Looping to generate QVD</title>
      <link>https://community.qlik.com/t5/App-Development/Looping-to-generate-QVD/m-p/1746651#M57336</link>
      <description>&lt;P&gt;Dear Steve,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes I've completed the app and did just as what you mentioned. Thanks for the feedback, really appreciate it.&amp;nbsp; I attached the apps here for anyone reference.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Hannan&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 06:35:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Looping-to-generate-QVD/m-p/1746651#M57336</guid>
      <dc:creator>Hann</dc:creator>
      <dc:date>2020-09-24T06:35:33Z</dc:date>
    </item>
  </channel>
</rss>

