<?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 Help me out to understand the below script with IterNo() in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Help-me-out-to-understand-the-below-script-with-IterNo/m-p/191655#M713912</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;STRONG&gt;Attitude ,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;This function is only meaningful if used together with a &lt;A href="http://community.qlik.com/forums/Load.htm#while"&gt;while&lt;/A&gt; clause. IterNo( ) returns an integer indicating for which time one single record is evaluated in a load statement with a while clause. The first iteration has number 1.&lt;/P&gt;&lt;P&gt;For Example Your Fields Havng the example data:&lt;/P&gt;&lt;P&gt;StartDate EndDate&lt;/P&gt;&lt;P&gt;1/1/2011 3/1/2011&lt;/P&gt;&lt;P&gt;2/1/2011 4/1/2011&lt;/P&gt;&lt;P&gt;3/1/2011 4/1/2011&lt;/P&gt;&lt;P&gt;for the firat iteration ( loading first row), the ItrNo() returns 1, for the second row itrNo() returns 2.. and so on..&lt;/P&gt;&lt;P&gt;so, DATE(StartDate+IterNo()-1) AS date&lt;/P&gt;&lt;P&gt;means DATE(StartDate+1-1) AS date --&amp;gt; next date.. finally the reulatant table like this...&lt;/P&gt;&lt;P&gt;StartDate EndDate DATE(StartDate+1-1) &amp;lt;= EndDate Date&lt;/P&gt;&lt;P&gt;1/1/2011 3/1/2011 DATE(1/1/2011 +1-1) 1/1/2011 &amp;lt;=3/1/2011 true 1/1/2011&lt;/P&gt;&lt;P&gt;2/1/2011 4/1/2011 DATE(2/1/2011 +2-1) 3/1/2011&amp;lt;=4/1/2011 true 3/1/2011&lt;/P&gt;&lt;P&gt;3/1/2011 4/1/2011 DATE(3/1/2011 +3-1) 5/1/2011&amp;lt;= 4/1/2011 false -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 31 Mar 2011 08:12:08 GMT</pubDate>
    <dc:creator />
    <dc:date>2011-03-31T08:12:08Z</dc:date>
    <item>
      <title>Help me out to understand the below script with IterNo()</title>
      <link>https://community.qlik.com/t5/QlikView/Help-me-out-to-understand-the-below-script-with-IterNo/m-p/191652#M713909</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;This script I have found in a example application. Though it works per my requirement I want to know how does this script work so that in future if any changes are required then I can do it myself instead of depending on some one to proceed further.&lt;/P&gt;&lt;P&gt;Can some one help me out to understand the below script as I could get enough details from the tutorial regarding iterno(). So I could understand what exactly this script(Bold letters!) does.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE ___default_attr="plain" class="jive_text_macro jive_macro_code" jivemacro="code"&gt;&lt;BR /&gt;Data:&lt;BR /&gt;LOAD A1,&lt;BR /&gt; A2,&lt;BR /&gt; A3,&lt;BR /&gt; A4,&lt;BR /&gt; A5,&lt;BR /&gt; [1],&lt;BR /&gt; Datee,&lt;BR /&gt; StartDate,&lt;BR /&gt; EndDate&lt;BR /&gt;FROM&lt;BR /&gt;C:\Sample5.xlsx&lt;BR /&gt;(ooxml, embedded labels, table is Sheet1);&lt;BR /&gt;Calendar:&lt;BR /&gt;LOAD DISTINCT&lt;BR /&gt; DATE(StartDate+IterNo()-1) AS date&lt;BR /&gt;RESIDENT Data&lt;BR /&gt;WHILE StartDate+IterNo()-1&amp;lt;=EndDate;&lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Mar 2011 07:42:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-me-out-to-understand-the-below-script-with-IterNo/m-p/191652#M713909</guid>
      <dc:creator />
      <dc:date>2011-03-31T07:42:23Z</dc:date>
    </item>
    <item>
      <title>Help me out to understand the below script with IterNo()</title>
      <link>https://community.qlik.com/t5/QlikView/Help-me-out-to-understand-the-below-script-with-IterNo/m-p/191653#M713910</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin:0cm 0cm 10pt;"&gt;Hi,&lt;/P&gt;&lt;P style="margin:0cm 0cm 10pt;"&gt;This script will create a date for each day between StartDate and EndDate, and that for each line of the Data table.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Mar 2011 08:01:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-me-out-to-understand-the-below-script-with-IterNo/m-p/191653#M713910</guid>
      <dc:creator />
      <dc:date>2011-03-31T08:01:53Z</dc:date>
    </item>
    <item>
      <title>Help me out to understand the below script with IterNo()</title>
      <link>https://community.qlik.com/t5/QlikView/Help-me-out-to-understand-the-below-script-with-IterNo/m-p/191654#M713911</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin:0cm 0cm 10pt;"&gt;Ok, more details :&lt;/P&gt;&lt;P style="margin:0cm 0cm 10pt;"&gt;The while clause will keep on loading a record while the condition is false. In your example, the first line of table Data will be loaded, IterNo (for iteration) will be 1, so StartDate-IterNo+1 will be start date, and as this is below EndDate, this first record will be loaded a second time, with IterNo = 2, and so on until EndDate. The second record of table date will be processed in the same way.&lt;/P&gt;&lt;P style="margin:0cm 0cm 10pt;"&gt;To better understand this try a simple script like :&lt;/P&gt;&lt;P style="margin:0cm 0cm 10pt;"&gt;&lt;/P&gt;&lt;P style="margin:0cm 0cm 10pt;"&gt;Data:&lt;BR /&gt;load * inline [&lt;BR /&gt; StartDate, EndDate, id&lt;BR /&gt; 1, 5, a&lt;BR /&gt; 3, 8, b&lt;BR /&gt; 2, 4, c&lt;BR /&gt; 12, 14, d&lt;BR /&gt;];&lt;/P&gt;&lt;P style="margin:0cm 0cm 10pt;"&gt;Calendar:&lt;BR /&gt;LOAD DISTINCT (StartDate+IterNo()-1) AS date, id as id2, IterNo() as IterNo, rowNo() as rowNo&lt;BR /&gt;RESIDENT Data&lt;BR /&gt;WHILE StartDate+IterNo()-1&amp;lt;=EndDate;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Mar 2011 08:11:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-me-out-to-understand-the-below-script-with-IterNo/m-p/191654#M713911</guid>
      <dc:creator />
      <dc:date>2011-03-31T08:11:54Z</dc:date>
    </item>
    <item>
      <title>Help me out to understand the below script with IterNo()</title>
      <link>https://community.qlik.com/t5/QlikView/Help-me-out-to-understand-the-below-script-with-IterNo/m-p/191655#M713912</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;STRONG&gt;Attitude ,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;This function is only meaningful if used together with a &lt;A href="http://community.qlik.com/forums/Load.htm#while"&gt;while&lt;/A&gt; clause. IterNo( ) returns an integer indicating for which time one single record is evaluated in a load statement with a while clause. The first iteration has number 1.&lt;/P&gt;&lt;P&gt;For Example Your Fields Havng the example data:&lt;/P&gt;&lt;P&gt;StartDate EndDate&lt;/P&gt;&lt;P&gt;1/1/2011 3/1/2011&lt;/P&gt;&lt;P&gt;2/1/2011 4/1/2011&lt;/P&gt;&lt;P&gt;3/1/2011 4/1/2011&lt;/P&gt;&lt;P&gt;for the firat iteration ( loading first row), the ItrNo() returns 1, for the second row itrNo() returns 2.. and so on..&lt;/P&gt;&lt;P&gt;so, DATE(StartDate+IterNo()-1) AS date&lt;/P&gt;&lt;P&gt;means DATE(StartDate+1-1) AS date --&amp;gt; next date.. finally the reulatant table like this...&lt;/P&gt;&lt;P&gt;StartDate EndDate DATE(StartDate+1-1) &amp;lt;= EndDate Date&lt;/P&gt;&lt;P&gt;1/1/2011 3/1/2011 DATE(1/1/2011 +1-1) 1/1/2011 &amp;lt;=3/1/2011 true 1/1/2011&lt;/P&gt;&lt;P&gt;2/1/2011 4/1/2011 DATE(2/1/2011 +2-1) 3/1/2011&amp;lt;=4/1/2011 true 3/1/2011&lt;/P&gt;&lt;P&gt;3/1/2011 4/1/2011 DATE(3/1/2011 +3-1) 5/1/2011&amp;lt;= 4/1/2011 false -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Mar 2011 08:12:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-me-out-to-understand-the-below-script-with-IterNo/m-p/191655#M713912</guid>
      <dc:creator />
      <dc:date>2011-03-31T08:12:08Z</dc:date>
    </item>
    <item>
      <title>Help me out to understand the below script with IterNo()</title>
      <link>https://community.qlik.com/t5/QlikView/Help-me-out-to-understand-the-below-script-with-IterNo/m-p/191656#M713913</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Renaud &amp;amp; Arun&lt;/P&gt;&lt;P&gt;Thanks a lot for your help and time. I am able to understand very clearly about IterNo() now hope I can use it in my application without any doubt :-).&lt;/P&gt;&lt;P&gt;Special thanks to arun for explaining the use of IterNo with example. Which helped me to understand things much better.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Apr 2011 06:00:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-me-out-to-understand-the-below-script-with-IterNo/m-p/191656#M713913</guid>
      <dc:creator />
      <dc:date>2011-04-01T06:00:00Z</dc:date>
    </item>
    <item>
      <title>Re: Help me out to understand the below script with IterNo()</title>
      <link>https://community.qlik.com/t5/QlikView/Help-me-out-to-understand-the-below-script-with-IterNo/m-p/191657#M713914</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;Replying late to this post. IterNo gets the number of iterations performed so far.&lt;/P&gt;&lt;P&gt;By this def, it makes sense that it can only be used with some loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ex. &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;STRONG&gt;AUTOGENERATE (1) WHILE $(vMinDate) + IterNo() - 1 &amp;lt;= &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;STRONG&gt;$(vMaxDate)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We can use the above logic to generate date ranges of size one day starting&lt;/P&gt;&lt;P&gt;from vMinDate to vMaxDate (variables). Btw, QV stores dates as number of days&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It seems to me that QV stores the &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;number of iterations somewhere and gets &lt;BR /&gt;that value from IterNo(). &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, the above loop is like this in any programming language -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;int count = 0;// like iterNo&lt;/P&gt;&lt;P&gt;int vMinDate = 11; // say 11th day from Jan 1.&lt;/P&gt;&lt;P&gt;int vMaxDate = 15&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;while(&amp;nbsp; (vMinDate + count) &amp;lt; vMaxDate )&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; starts = vMinDate&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ends = vMinDate + 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(starts, ends);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; count = count + 1;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Output -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;starts, ends&lt;/P&gt;&lt;P&gt;11,12&lt;/P&gt;&lt;P&gt;12,13,&lt;/P&gt;&lt;P&gt;13,14&lt;/P&gt;&lt;P&gt;14,15&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Mar 2014 22:14:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-me-out-to-understand-the-below-script-with-IterNo/m-p/191657#M713914</guid>
      <dc:creator />
      <dc:date>2014-03-26T22:14:27Z</dc:date>
    </item>
  </channel>
</rss>

