<?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: Loop through months in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Loop-through-months/m-p/493219#M480750</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you mean variables or fields? If you create a loop that changes the value of a variable in each iteration then after the loop ends you will still have only one variable that will have only one value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Actually, why don't you start by explaining what your source data is and what the end result is that you're looking for.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 07 Nov 2013 12:51:59 GMT</pubDate>
    <dc:creator>Gysbert_Wassenaar</dc:creator>
    <dc:date>2013-11-07T12:51:59Z</dc:date>
    <item>
      <title>Loop through months</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-months/m-p/493217#M480748</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to put a loop on a LOAD statement with the following requirements:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;A start &amp;amp; end date are defined as non-changing values&lt;/LI&gt;&lt;LI&gt;The loop needs to update 2 other variables which I need to include into the load statement&lt;UL&gt;&lt;LI&gt;Variable 1: The 1st day of the month (in yyyy-mm-dd format)&lt;/LI&gt;&lt;LI&gt;Variable 2: The last day of the month (also in yyyy-mm-dd format)&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;The loop needs loop through all months starting with the month of the "startdate" and ending with the month of the "enddate" and generate the first and last day of each month into the variables (as described above)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Assume:&lt;/P&gt;&lt;P&gt;Startdate: 2013-01-01&lt;/P&gt;&lt;P&gt;End date: 2013-11-07&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Values I want to generate in the first loop:&lt;/P&gt;&lt;P&gt;vSDate: 2013-01-01&lt;/P&gt;&lt;P&gt;vEDate: 2013-01-31&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Values I want to generate in the second loop:&lt;/P&gt;&lt;P&gt;vSDate: 2013-02-01&lt;/P&gt;&lt;P&gt;vEDate: 2013-02-28&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;etc etc..., ending with in the last loop:&lt;/P&gt;&lt;P&gt;vSDate: 2013-11-01&lt;/P&gt;&lt;P&gt;vEDate: 2013-11-30&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was able to do this crawling through the loop day by day, using the formula below, but I'm unable to do the same to loop through the months:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;EM&gt;for zi = date(vStartDateGA,'YYYY-MM') to date(vEndDateGA,'YYYY-MM')&lt;/EM&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Let zDate = Date(zi,'YYYY-MM-DD');&lt;/EM&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; let eDate = MonthEnd(date(zi,'YYYY-MM-DD'));&lt;/EM&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;EM&gt;next&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Christophe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Nov 2013 12:39:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-months/m-p/493217#M480748</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-07T12:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through months</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-months/m-p/493218#M480749</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro _jivemacro_uid_13838285000933552 jive_macro_code" jivemacro_uid="_13838285000933552"&gt;
&lt;P&gt;SET DateFormat='YYYY-MM-DD';&lt;/P&gt;
&lt;P&gt;LET vStartDateGA = '2011-10-01';&lt;/P&gt;
&lt;P&gt;LET vEndDateGA = '2013-12-01';&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;do while vStartDateGA &amp;lt;= vEndDateGA&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; Let zDate = MonthStart(date('$(vStartDateGA)','YYYY-MM-DD'));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; let eDate = MonthEnd(date('$(vStartDateGA)','YYYY-MM-DD'));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; let vStartDateGA = date(AddMonths('$(vStartDateGA)',1),'YYYY-MM-DD');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;loop&amp;nbsp; &lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Nov 2013 12:48:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-months/m-p/493218#M480749</guid>
      <dc:creator>Clever_Anjos</dc:creator>
      <dc:date>2013-11-07T12:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through months</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-months/m-p/493219#M480750</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you mean variables or fields? If you create a loop that changes the value of a variable in each iteration then after the loop ends you will still have only one variable that will have only one value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Actually, why don't you start by explaining what your source data is and what the end result is that you're looking for.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Nov 2013 12:51:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-months/m-p/493219#M480750</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2013-11-07T12:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through months</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-months/m-p/493220#M480751</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-style: inherit; color: black; background-color: inherit; font-size: 9pt !important;"&gt;This will always be true so the loop never ends: &lt;EM&gt;do while vStartDateGA &amp;lt;= vEndDateGA&amp;nbsp; &lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Nov 2013 12:53:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-months/m-p/493220#M480751</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2013-11-07T12:53:09Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through months</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-months/m-p/493221#M480752</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Worked like a charm ! Thanks !&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Nov 2013 09:03:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-months/m-p/493221#M480752</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-14T09:03:09Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through months</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-months/m-p/493222#M480753</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I´m overriding it inside the loop&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt; let vStartDateGA = date(AddMonths('$(vStartDateGA)',1),'YYYY-MM-DD'); &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Nov 2013 11:07:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-months/m-p/493222#M480753</guid>
      <dc:creator>Clever_Anjos</dc:creator>
      <dc:date>2013-11-14T11:07:57Z</dc:date>
    </item>
  </channel>
</rss>

