<?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 every year. in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Loop-through-months-in-every-year/m-p/1007981#M959043</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ganesh, weird way to do the loop, you can't add '1' to 'i' and 'j' each iteration:&lt;/P&gt;&lt;P&gt;if this starts with 01/1977 i=1, J=1977, next iteration will be i=2, J=1978&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;following this approach you can check when to add 1 to j:&lt;/P&gt;&lt;P&gt;Try Changing:&lt;/P&gt;&lt;P&gt;Let i=i+1;&lt;/P&gt;&lt;P&gt;let j=j+1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To:&lt;/P&gt;&lt;P&gt;Let j=If(i=12, j+1, j);&lt;/P&gt;&lt;P&gt;Let i=If(i=12, 1, i+1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another thing, in the where you're using &amp;gt;= and &amp;lt;=, so each iteration will have 2 months loaded, maybe you need to remove the '=' in one of the conditions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 Nov 2015 12:39:33 GMT</pubDate>
    <dc:creator>rubenmarin</dc:creator>
    <dc:date>2015-11-02T12:39:33Z</dc:date>
    <item>
      <title>Loop through months in every year.</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-months-in-every-year/m-p/1007979#M959041</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;Here i am calculating metrics by looping through months in every year (Ex : i got data from 1977 to 2018) , below code is not working . can anyone suggest how to increment year value correctly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: i need to use minMonth and maxMonth due to where condition&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Temp_month:&lt;/P&gt;&lt;P&gt;load num(min(Month(wo_completionDate))) as minMonth,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; num(max(Month(wo_completionDate))) as maxMonth,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; min(year(wo_completionDate)) as minYear,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; max(year(wo_completionDate)) as maxYear&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;from $(vQVDDataDir)\ WO.qvd (qvd)&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;let vMinMonth= peek('minMonth');&lt;/P&gt;&lt;P&gt;let vMaxMonth= peek('maxMonth');&lt;/P&gt;&lt;P&gt;let vMinYear=peek('minYear');&lt;/P&gt;&lt;P&gt;let vMaxYear=peek('maxYear');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;let i=$(vMinMonth);&lt;/P&gt;&lt;P&gt;let j=$(vMinYear);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do while i&amp;lt;=$(vMaxMonth) and j&amp;lt;=$(vMaxYear)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;join(Summary)&lt;/P&gt;&lt;P&gt;load&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '$(i)' as Month,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '$(j)' as Year,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fd_code as [Client source],&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; count(if(code=1 and&amp;nbsp; wc_code = '01' and&amp;nbsp; Diff &amp;lt;=1 , wo )) as CorrWoPriority1Num,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; count(if(pricode=1 and&amp;nbsp; wc_code = '01'&amp;nbsp; ,wo_number)) as CorrWoPriority1Den,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; count(if(code=2 and&amp;nbsp; wc&amp;nbsp; = '01' and&amp;nbsp; Diff &amp;lt;=2,wo )) as CorrWoPriority2Num,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; count(if(code=2 and&amp;nbsp; wc&amp;nbsp; = '01' ,wo_number)) as CorrWoPriority2Den,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; count(if(code=3 and&amp;nbsp; wc = '01' and&amp;nbsp; Diff &amp;lt;=28,wo )) as CorrWoPriority3Num,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; count(if(code=3 and&amp;nbsp; wc = '01'&amp;nbsp; ,wo_number)) as CorrWoPriority3Den,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; count(if(ode=4 and&amp;nbsp; wc&amp;nbsp; = '01' and&amp;nbsp; Diff &amp;lt;=14 ,wo )) as CorrWoPriority4Num,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; count(if(code=4 and&amp;nbsp; wc&amp;nbsp; = '01'&amp;nbsp; ,wo )) as CorrWoPriority4Den&lt;/P&gt;&lt;P&gt;&amp;nbsp; from $(vQVDDataDir)\ WO.qvd (qvd)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where num(month(floor(wo_completionDate))) &amp;gt;= '$(i)'-1 and num(month(floor(wo_completionDate))) &amp;lt;= '$(i)'&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and isnull(proj_number)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; group By&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fd_code&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Let i=i+1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; let j=j+1;&lt;/P&gt;&lt;P&gt;LOOP&lt;/P&gt;&lt;P&gt; &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;STORE Summary INTO [$(vQVDDataDir) summary.qvd] (qvd);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Ganesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2015 11:39:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-months-in-every-year/m-p/1007979#M959041</guid>
      <dc:creator>ganeshreddy</dc:creator>
      <dc:date>2015-11-02T11:39:55Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through months in every year.</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-months-in-every-year/m-p/1007980#M959042</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ganesh,&lt;/P&gt;&lt;P&gt;please explain more what is the problem you are trying to solve here, what is the requirement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also you should verify your code because it seems to be that some fields are named incorreclty, like this:&lt;/P&gt;&lt;P&gt;count(if(&lt;STRONG style="text-decoration: underline;"&gt;ode&lt;/STRONG&gt;=4 and&amp;nbsp; wc&amp;nbsp; = '01' and&amp;nbsp; Diff &amp;lt;=14 ,wo )) as CorrWoPriority4Num,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kindest regards,&lt;/P&gt;&lt;P&gt;Santiago Respane&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2015 12:24:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-months-in-every-year/m-p/1007980#M959042</guid>
      <dc:creator>santiago_respane</dc:creator>
      <dc:date>2015-11-02T12:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through months in every year.</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-months-in-every-year/m-p/1007981#M959043</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ganesh, weird way to do the loop, you can't add '1' to 'i' and 'j' each iteration:&lt;/P&gt;&lt;P&gt;if this starts with 01/1977 i=1, J=1977, next iteration will be i=2, J=1978&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;following this approach you can check when to add 1 to j:&lt;/P&gt;&lt;P&gt;Try Changing:&lt;/P&gt;&lt;P&gt;Let i=i+1;&lt;/P&gt;&lt;P&gt;let j=j+1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To:&lt;/P&gt;&lt;P&gt;Let j=If(i=12, j+1, j);&lt;/P&gt;&lt;P&gt;Let i=If(i=12, 1, i+1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another thing, in the where you're using &amp;gt;= and &amp;lt;=, so each iteration will have 2 months loaded, maybe you need to remove the '=' in one of the conditions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2015 12:39:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-months-in-every-year/m-p/1007981#M959043</guid>
      <dc:creator>rubenmarin</dc:creator>
      <dc:date>2015-11-02T12:39:33Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through months in every year.</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-months-in-every-year/m-p/1007982#M959044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI ,&lt;/P&gt;&lt;P&gt;Try some thing like below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use FOR loop here, if Min month and max month are available you can use them or&lt;/P&gt;&lt;P&gt;else create them like&lt;/P&gt;&lt;P&gt;vMinMonth=1;&lt;/P&gt;&lt;P&gt;vmaxMonth=12;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FOR i=$(vMinYear)-1 to $(vMaxYear)-1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FOR j=$(vMinMonth) to $(vMaxMonth)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;$(J) as Month,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;$(i)+1 as Year,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="line-height: 1.5em; color: #3d3d3d; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;fd_code as [Client source],&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="line-height: 1.5em; color: #3d3d3d; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="line-height: 1.5em; color: #3d3d3d; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="line-height: 1.5em; color: #3d3d3d; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="line-height: 1.5em; color: #3d3d3d; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="line-height: 1.5em; color: #3d3d3d; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NEXT&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; line-height: 1.5em;"&gt;&lt;STRONG&gt;NEXT&lt;/STRONG&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2015 13:09:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-months-in-every-year/m-p/1007982#M959044</guid>
      <dc:creator>sasikanth</dc:creator>
      <dc:date>2015-11-02T13:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through months in every year.</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-months-in-every-year/m-p/1007983#M959045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;btw, you also need to change the while conditions to:&lt;/P&gt;&lt;P&gt;do while j&amp;lt;$(vMaxYear) or (i&amp;lt;=$(vMaxMonth) and j=$(vMaxYear))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2015 13:41:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-months-in-every-year/m-p/1007983#M959045</guid>
      <dc:creator>rubenmarin</dc:creator>
      <dc:date>2015-11-02T13:41:23Z</dc:date>
    </item>
  </channel>
</rss>

