<?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 in script in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/loop-in-script/m-p/361113#M1169591</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;Have you checked if the dates you are using for comparison can't be obtained based on the current row you are reading for your table? Because loop structures in your script can increase the script execution time, so is best to avoid them...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway, if you are right to choose this path you can use something like this:&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 $(variable) = 0 to 1000&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(field &amp;gt; $(variable), ...)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AUTOGENERATE(1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;NEXT&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 20 Jul 2012 15:09:05 GMT</pubDate>
    <dc:creator>cesaraccardi</dc:creator>
    <dc:date>2012-07-20T15:09:05Z</dc:date>
    <item>
      <title>loop in script</title>
      <link>https://community.qlik.com/t5/QlikView/loop-in-script/m-p/361112#M1169590</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dears, &lt;/P&gt;&lt;P&gt;I have a file with script when I use many many times if function to compare dates and create a field.&lt;/P&gt;&lt;P&gt;I am creating fields called '01.2011', '01.2012' etc based on a function e.g.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;&lt;SPAN style=": ; color: #0000ff; font-size: 8pt;"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;if&lt;/P&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;pst.date&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &amp;gt;= '06.02.2011', 'n/a', &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;status&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; = 'open' &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;or&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;[clearing date]&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &amp;gt; '06.02.2011' &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;or&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; (&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;pst.date&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &amp;lt;= '31.12.2010' &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;[clearing date]&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &amp;gt; '06.02.2011'),'X','-')) &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;[01.2011],&lt;/SPAN&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;Because i have such a line for every period from 2009-2012 I thought I could you maybe loop instead. However, I dont have idea how to do that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I attached a file with sample of three lines of such code and also the two source files.&lt;/P&gt;&lt;P&gt;In tab v.3 I mapped all info from one table to another in case it is needed.&lt;/P&gt;&lt;P&gt; Does anyone how to replace the if lines with loop?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance&lt;/P&gt;&lt;P&gt;justyna&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Jul 2012 14:55:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/loop-in-script/m-p/361112#M1169590</guid>
      <dc:creator />
      <dc:date>2012-07-20T14:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: loop in script</title>
      <link>https://community.qlik.com/t5/QlikView/loop-in-script/m-p/361113#M1169591</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;Have you checked if the dates you are using for comparison can't be obtained based on the current row you are reading for your table? Because loop structures in your script can increase the script execution time, so is best to avoid them...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway, if you are right to choose this path you can use something like this:&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 $(variable) = 0 to 1000&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(field &amp;gt; $(variable), ...)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AUTOGENERATE(1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;NEXT&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Jul 2012 15:09:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/loop-in-script/m-p/361113#M1169591</guid>
      <dc:creator>cesaraccardi</dc:creator>
      <dc:date>2012-07-20T15:09:05Z</dc:date>
    </item>
  </channel>
</rss>

