<?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: Variables in FOR loop in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Variables-in-FOR-loop/m-p/552810#M206537</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Can you show your script of assigning value to variable Z? Are you using SET or LET?&lt;/P&gt;&lt;P&gt;I guess something is going wrong in assigning statement, the value for Z that you are seeing after the script execution might be previously loaded value.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 31 Oct 2013 05:50:35 GMT</pubDate>
    <dc:creator />
    <dc:date>2013-10-31T05:50:35Z</dc:date>
    <item>
      <title>Variables in FOR loop</title>
      <link>https://community.qlik.com/t5/QlikView/Variables-in-FOR-loop/m-p/552807#M206534</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a file raw_data.qvd that already exists, and I am trying to do an incremental load to add new excel files to the qvd.&amp;nbsp; It works fine if I do a loop from 1 to a variable, but not for a variable to a variable.&amp;nbsp; So how do I get it to work so I don't have to start with a fixed number all the time?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When it runs, I get this error - notice the first variable is blank:&lt;/P&gt;&lt;P&gt;Script line error: &lt;BR /&gt;FOR a= to 9&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is what I end up with in my data table for the variables, so I know they are resolving correctly:&lt;/P&gt;&lt;P&gt;$(N)&amp;nbsp;&amp;nbsp; $(Z)&lt;BR /&gt;9&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;For this example let's say I have 7 files already loaded, and there are two new ones (8 &amp;amp; 9) that need to be loaded. I want the FOR to end up being "FOR a=8 to 9"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FOR a=$(Z) to $(N);&lt;/P&gt;&lt;P&gt;// ^ this doesn't work - $(Z) comes up as blank in the FOR but loads the expected value in the LOAD later on&lt;/P&gt;&lt;P&gt;FOR a=1 to $(N);&lt;/P&gt;&lt;P&gt;// ^ this works fine, but I don't want to start at 1.&amp;nbsp; The $(N) variable works fine in both examples&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let FileName = 'PATH\TEST_$(a).xlsx';&lt;BR /&gt;// $(a) is a variable representing the numbered file name aka TEST_1.xlsx, TEST_1.xlsx, etc.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data:&lt;BR /&gt;LOAD *&lt;BR /&gt;, $(Z) as var_z&lt;BR /&gt;, $(N) as var_n&lt;/P&gt;&lt;P&gt;, $(a) as var_a&lt;BR /&gt;FROM&lt;BR /&gt;$(FileName)&lt;BR /&gt;(ooxml, embedded labels, table is Sheet1);&lt;BR /&gt;Next&lt;BR /&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Oct 2013 05:23:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variables-in-FOR-loop/m-p/552807#M206534</guid>
      <dc:creator />
      <dc:date>2013-10-31T05:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: Variables in FOR loop</title>
      <link>https://community.qlik.com/t5/QlikView/Variables-in-FOR-loop/m-p/552808#M206535</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;The problem is before the loop, as Z is not being determined before the loop start. Test this by forcing Z to a value of 8 before the loop, or use a TRACE Z = $(Z) command before the loop starts. You could also step through the script in debug mode to see what is happening when you calculate Z.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH&lt;/P&gt;&lt;P&gt;Jonathan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Oct 2013 05:34:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variables-in-FOR-loop/m-p/552808#M206535</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2013-10-31T05:34:58Z</dc:date>
    </item>
    <item>
      <title>Re: Variables in FOR loop</title>
      <link>https://community.qlik.com/t5/QlikView/Variables-in-FOR-loop/m-p/552809#M206536</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I set the Z variable earlier, just didn't include it in the example.&amp;nbsp; When I get my data table in the end, the Z variable is populated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Oct 2013 05:37:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variables-in-FOR-loop/m-p/552809#M206536</guid>
      <dc:creator />
      <dc:date>2013-10-31T05:37:36Z</dc:date>
    </item>
    <item>
      <title>Re: Variables in FOR loop</title>
      <link>https://community.qlik.com/t5/QlikView/Variables-in-FOR-loop/m-p/552810#M206537</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Can you show your script of assigning value to variable Z? Are you using SET or LET?&lt;/P&gt;&lt;P&gt;I guess something is going wrong in assigning statement, the value for Z that you are seeing after the script execution might be previously loaded value.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Oct 2013 05:50:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variables-in-FOR-loop/m-p/552810#M206537</guid>
      <dc:creator />
      <dc:date>2013-10-31T05:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: Variables in FOR loop</title>
      <link>https://community.qlik.com/t5/QlikView/Variables-in-FOR-loop/m-p/552811#M206538</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Christine&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you are mistaken - it seems that Z is not populated (at least not with a number) when the FOR statement is executed . What Z is at the end of the script is not the point. If I were solving this problem, I would step through the code before the loop in the debugger, and see what Z is doing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Jonathan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Oct 2013 05:51:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variables-in-FOR-loop/m-p/552811#M206538</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2013-10-31T05:51:23Z</dc:date>
    </item>
    <item>
      <title>Re: Variables in FOR loop</title>
      <link>https://community.qlik.com/t5/QlikView/Variables-in-FOR-loop/m-p/552812#M206539</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Christine Hill&lt;/P&gt;&lt;P&gt;There is no problem with u r code ...but Try this replace&amp;nbsp; function in place of Z variable like NoOfRows('tablename')&lt;/P&gt;&lt;P&gt;For a=$(n) to NoOfrows('tablename')&lt;/P&gt;&lt;P&gt;I am not sure but may help you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Oct 2013 05:55:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variables-in-FOR-loop/m-p/552812#M206539</guid>
      <dc:creator>sasikanth</dc:creator>
      <dc:date>2013-10-31T05:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: Variables in FOR loop</title>
      <link>https://community.qlik.com/t5/QlikView/Variables-in-FOR-loop/m-p/552813#M206540</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah, you guys are right!&amp;nbsp; I don't know how the variable was making it to the end ok since I was only setting it in one place.&amp;nbsp; I tweaked it a little and got it to run.&amp;nbsp; Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Oct 2013 06:23:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variables-in-FOR-loop/m-p/552813#M206540</guid>
      <dc:creator />
      <dc:date>2013-10-31T06:23:12Z</dc:date>
    </item>
  </channel>
</rss>

