<?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: for loop with dates in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/for-loop-with-dates/m-p/1280015#M860908</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you try with &lt;SPAN class="statement" data-mc-conditions="Primary.NotToTranslate" style="font-weight: bold; color: #0f0f0f; font-family: 'Open Sans', Arial, sans-serif; font-size: 14px;"&gt;FirstSortedValue()&lt;/SPAN&gt;&lt;SPAN style="color: #0f0f0f; font-family: 'Open Sans', Arial, sans-serif; font-size: 14px;"&gt; &lt;/SPAN&gt; ?&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.qlik.com/en-US/qlikview/12.0/Subsystems/Client/Content/Scripting/AggregationFunctions/firstsorted.htm" title="https://help.qlik.com/en-US/qlikview/12.0/Subsystems/Client/Content/Scripting/AggregationFunctions/firstsorted.htm"&gt;https://help.qlik.com/en-US/qlikview/12.0/Subsystems/Client/Content/Scripting/AggregationFunctions/firstsorted.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 05 Jan 2017 20:59:34 GMT</pubDate>
    <dc:creator />
    <dc:date>2017-01-05T20:59:34Z</dc:date>
    <item>
      <title>for loop with dates</title>
      <link>https://community.qlik.com/t5/QlikView/for-loop-with-dates/m-p/1280013#M860906</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this is my script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;S_PERSONAL_A_Team:&lt;/P&gt;&lt;P&gt;LOAD &lt;/P&gt;&lt;P&gt;&amp;nbsp; date('01/'&amp;amp;RIGHT(KEY_4,7),'DD/MM/YYYY') as MONTH_YEAR, // '01/06/2016' &lt;/P&gt;&lt;P&gt;&amp;nbsp; Team as S_TEAM_NAME,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MAX_PERSONAL_AVG as S_MAX_PERSONAL_AVG&lt;/P&gt;&lt;P&gt;RESIDENT PERSONAL_A_Team;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TEMP_MAX_MIN_DATE:&lt;/P&gt;&lt;P&gt;LOAD MAX(MONTH_YEAR) AS MAX_S_MONTH_YEAR,&lt;/P&gt;&lt;P&gt;&amp;nbsp; MIN(MONTH_YEAR) AS MIN_S_MONTH_YEAR&lt;/P&gt;&lt;P&gt;RESIDENT S_PERSONAL_A_Team;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SET DateFormat='DD/MM/YYYY';&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET vMinTempDate = Peek('MIN_S_MONTH_YEAR',0,'TEMP_MAX_MIN_DATE');&amp;nbsp; &lt;/P&gt;&lt;P&gt;LET vMaxTempDate = Peek('MAX_S_MONTH_YEAR',0,'TEMP_MAX_MIN_DATE');&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FOR i= $(vMinTempDate) to $(vMaxTempDate)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;let Z= '01'&amp;amp;'/'&amp;amp;right(date($(i)),7);&amp;nbsp; // since the loop running on months i always set it to the first day&lt;/P&gt;&lt;P&gt;let j= date(AddMonths('01'&amp;amp;'/'&amp;amp;right(date($(i)),7),-2),'DD/MM/YYYY'); // variable of two months ago&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TEMP_S_PERSONAL_A_Team:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD&amp;nbsp; S_TEAM_NAME&amp;amp;'/'&amp;amp;right(date($(Z)),7) as KEY_4,&lt;/P&gt;&lt;P&gt;S_TEAM_NAME as S_TEAM_NAME_NEW,&lt;/P&gt;&lt;P&gt;&amp;nbsp; $(Z) as new_S_MONTH_YEAR,&lt;/P&gt;&lt;P&gt;// $(j) as two_months_ago,&lt;/P&gt;&lt;P&gt;MAX(S_MAX_PERSONAL_AVG) as maxScore&lt;/P&gt;&lt;P&gt;RESIDENT S_PERSONAL_A_Team&lt;/P&gt;&lt;P&gt;where (S_MONTH_YEAR&amp;lt;=$(Z) and S_MONTH_YEAR&amp;gt;=$(j))&lt;/P&gt;&lt;P&gt;Group by S_TEAM_NAME,$(Z);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NEXT i&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;///////////////&lt;/P&gt;&lt;P&gt;I want to get a table that for each date (&lt;SPAN style="font-size: 13.3333px;"&gt;new_S_MONTH_YEAR&lt;/SPAN&gt;) I will get the maxSCore from i to j&lt;/P&gt;&lt;P&gt;my problem is that when I executing script 0 line fetched from &lt;SPAN style="font-size: 13.3333px;"&gt;TEMP_S_PERSONAL_A_Team.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/for-loop-with-dates/m-p/1280013#M860906</guid>
      <dc:creator />
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: for loop with dates</title>
      <link>https://community.qlik.com/t5/QlikView/for-loop-with-dates/m-p/1280014#M860907</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try checking the value for &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;vMinTempDate&lt;/SPAN&gt; and &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;vMaxTempDate&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;These must be numbers, not dates.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jan 2017 17:35:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/for-loop-with-dates/m-p/1280014#M860907</guid>
      <dc:creator>m_woolf</dc:creator>
      <dc:date>2017-01-05T17:35:05Z</dc:date>
    </item>
    <item>
      <title>Re: for loop with dates</title>
      <link>https://community.qlik.com/t5/QlikView/for-loop-with-dates/m-p/1280015#M860908</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you try with &lt;SPAN class="statement" data-mc-conditions="Primary.NotToTranslate" style="font-weight: bold; color: #0f0f0f; font-family: 'Open Sans', Arial, sans-serif; font-size: 14px;"&gt;FirstSortedValue()&lt;/SPAN&gt;&lt;SPAN style="color: #0f0f0f; font-family: 'Open Sans', Arial, sans-serif; font-size: 14px;"&gt; &lt;/SPAN&gt; ?&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.qlik.com/en-US/qlikview/12.0/Subsystems/Client/Content/Scripting/AggregationFunctions/firstsorted.htm" title="https://help.qlik.com/en-US/qlikview/12.0/Subsystems/Client/Content/Scripting/AggregationFunctions/firstsorted.htm"&gt;https://help.qlik.com/en-US/qlikview/12.0/Subsystems/Client/Content/Scripting/AggregationFunctions/firstsorted.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jan 2017 20:59:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/for-loop-with-dates/m-p/1280015#M860908</guid>
      <dc:creator />
      <dc:date>2017-01-05T20:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: for loop with dates</title>
      <link>https://community.qlik.com/t5/QlikView/for-loop-with-dates/m-p/1280016#M860909</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;your first LOAD seems to be wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The function Date(...) is wrong because the first parameter of this function need to be a number.&lt;/P&gt;&lt;P&gt;In your case, you need to use Date#(...) where the first paramete is a text.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 20px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM style="font-size: 8pt;"&gt;S_PERSONAL_A_Team:&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 20px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM style="font-size: 8pt;"&gt;LOAD&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 20px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM style="font-size: 8pt;"&gt;&amp;nbsp; &lt;SPAN style="color: #ff9900;"&gt;Date#&lt;/SPAN&gt;('01/'&amp;amp;RIGHT(KEY_4,7),'DD/MM/YYYY') as MONTH_YEAR, // '01/06/2016'&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 20px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM style="font-size: 8pt;"&gt;&amp;nbsp; Team as S_TEAM_NAME,&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 20px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MAX_PERSONAL_AVG as S_MAX_PERSONAL_AVG&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 20px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM style="font-size: 8pt;"&gt;RESIDENT PERSONAL_A_Team;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jan 2017 21:20:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/for-loop-with-dates/m-p/1280016#M860909</guid>
      <dc:creator>sfatoux72</dc:creator>
      <dc:date>2017-01-05T21:20:11Z</dc:date>
    </item>
    <item>
      <title>Re: for loop with dates</title>
      <link>https://community.qlik.com/t5/QlikView/for-loop-with-dates/m-p/1280017#M860910</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You were right, I added Num() and it worked, thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 08 Jan 2017 08:41:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/for-loop-with-dates/m-p/1280017#M860910</guid>
      <dc:creator />
      <dc:date>2017-01-08T08:41:42Z</dc:date>
    </item>
  </channel>
</rss>

