<?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: Building a FOR...NEXT loop based on Row_nrs. in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Building-a-FOR-NEXT-loop-based-on-Row-nrs/m-p/492776#M688723</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jonathan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NoOfRows() is a function I have used in another scenario already. I can well use that.&lt;/P&gt;&lt;P&gt;I merely think you have misunderstood me insofar as your code seems to be for something more complicated than I want - in the end, it is going to be quite complicated, but not at this stage. I will explain the entire scope of this task so you can better understand just what I need:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- I have, with some help from swuehl, developed a code that works fine for ONE employee. It involves&lt;/P&gt;&lt;P&gt;&amp;nbsp; - a MAPPING LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp; - several LOAD statements (from different tables, some of them concatenated)&lt;/P&gt;&lt;P&gt;&amp;nbsp; - a "blowup" of a table (to one_record_per_day)&lt;/P&gt;&lt;P&gt;- The next step is to execute that code in a LOOP for every employee we have&lt;/P&gt;&lt;P&gt;=&amp;gt; I have already developed a LOAD from the masterdata table that gives me 1 record per employee&lt;/P&gt;&lt;P&gt;=&amp;gt; Now I want to build the LOOP over that table&lt;/P&gt;&lt;P&gt;&amp;lt;=&amp;gt; However, that LOOP would be very large and probably quite hard to oversee. I wonder whether it might not be a better idea to&lt;/P&gt;&lt;P&gt;- develop a subroutine (well, that would just be the code I already have working on ONE employee_nr)&lt;/P&gt;&lt;P&gt;- build a LOOP over all the lines of that masterdata_table and in that LOOP&lt;/P&gt;&lt;P&gt;&amp;nbsp; - define a variable with the emp_id I find in that line&lt;/P&gt;&lt;P&gt;&amp;nbsp; - call the subroutine and pass that id_variable as a parameter to the subroutine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have very limited experience with subroutines, but I think there's nothing much to it, it's basically just a script.&lt;/P&gt;&lt;P&gt;Do you know of any pitfalls I have to keep in mind (like any customary script_commands that will NOT work inside a subroutine)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DataNibbler&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think that's better.&lt;/P&gt;&lt;P&gt;Is there&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 07 Nov 2013 11:35:37 GMT</pubDate>
    <dc:creator>datanibbler</dc:creator>
    <dc:date>2013-11-07T11:35:37Z</dc:date>
    <item>
      <title>Building a FOR...NEXT loop based on Row_nrs.</title>
      <link>https://community.qlik.com/t5/QlikView/Building-a-FOR-NEXT-loop-based-on-Row-nrs/m-p/492773#M688720</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;I have a preliminary question:&lt;/P&gt;&lt;P&gt;- I want to build a LOOP over all the lines of a table I have just loaded.&lt;/P&gt;&lt;P&gt;- In the LOAD statement, I load &amp;gt;&amp;gt;&amp;gt; RowNo() as Line &amp;lt;&amp;lt;&amp;lt;.&lt;/P&gt;&lt;P&gt;- It seems, however that I cannot define variables for the lower and upper bounds (based on that field) in the script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; I tried several times now - I can define those variables on the GUI no problem, but not in the script.&lt;/P&gt;&lt;P&gt;&amp;lt;=&amp;gt; I need those bounds in some form (variables or Fields) so I can set up my LOOP.&lt;/P&gt;&lt;P&gt;Can someone help me there, please?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DataNibbler&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Nov 2013 10:43:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Building-a-FOR-NEXT-loop-based-on-Row-nrs/m-p/492773#M688720</guid>
      <dc:creator>datanibbler</dc:creator>
      <dc:date>2013-11-07T10:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: Building a FOR...NEXT loop based on Row_nrs.</title>
      <link>https://community.qlik.com/t5/QlikView/Building-a-FOR-NEXT-loop-based-on-Row-nrs/m-p/492774#M688721</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;for i = 1 to noofrows('TableName')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do stuff&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;next&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Nov 2013 10:52:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Building-a-FOR-NEXT-loop-based-on-Row-nrs/m-p/492774#M688721</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2013-11-07T10:52:49Z</dc:date>
    </item>
    <item>
      <title>Re: Building a FOR...NEXT loop based on Row_nrs.</title>
      <link>https://community.qlik.com/t5/QlikView/Building-a-FOR-NEXT-loop-based-on-Row-nrs/m-p/492775#M688722</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 lower bound will be 0 (for peek) or 1 for row number. &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;The function NoOfRows('TableName') will in script return the number of rows loaded, so the upper bound would by that value (or value - 1 for peek).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let zSize = NoOfRows('TableName');&lt;/P&gt;&lt;P&gt;For zi = 0 To zSize - 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Let zValue = Peek('MyField', zi, 'TableName');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ... do something here ...&lt;/P&gt;&lt;P&gt;Next&lt;/P&gt;&lt;P&gt;Set zi = ;&lt;/P&gt;&lt;P&gt;Set zSize = ;&lt;/P&gt;&lt;P&gt;Set zValue = ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(Or have I misunderstood you?)&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, 07 Nov 2013 10:53:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Building-a-FOR-NEXT-loop-based-on-Row-nrs/m-p/492775#M688722</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2013-11-07T10:53:09Z</dc:date>
    </item>
    <item>
      <title>Re: Building a FOR...NEXT loop based on Row_nrs.</title>
      <link>https://community.qlik.com/t5/QlikView/Building-a-FOR-NEXT-loop-based-on-Row-nrs/m-p/492776#M688723</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jonathan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NoOfRows() is a function I have used in another scenario already. I can well use that.&lt;/P&gt;&lt;P&gt;I merely think you have misunderstood me insofar as your code seems to be for something more complicated than I want - in the end, it is going to be quite complicated, but not at this stage. I will explain the entire scope of this task so you can better understand just what I need:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- I have, with some help from swuehl, developed a code that works fine for ONE employee. It involves&lt;/P&gt;&lt;P&gt;&amp;nbsp; - a MAPPING LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp; - several LOAD statements (from different tables, some of them concatenated)&lt;/P&gt;&lt;P&gt;&amp;nbsp; - a "blowup" of a table (to one_record_per_day)&lt;/P&gt;&lt;P&gt;- The next step is to execute that code in a LOOP for every employee we have&lt;/P&gt;&lt;P&gt;=&amp;gt; I have already developed a LOAD from the masterdata table that gives me 1 record per employee&lt;/P&gt;&lt;P&gt;=&amp;gt; Now I want to build the LOOP over that table&lt;/P&gt;&lt;P&gt;&amp;lt;=&amp;gt; However, that LOOP would be very large and probably quite hard to oversee. I wonder whether it might not be a better idea to&lt;/P&gt;&lt;P&gt;- develop a subroutine (well, that would just be the code I already have working on ONE employee_nr)&lt;/P&gt;&lt;P&gt;- build a LOOP over all the lines of that masterdata_table and in that LOOP&lt;/P&gt;&lt;P&gt;&amp;nbsp; - define a variable with the emp_id I find in that line&lt;/P&gt;&lt;P&gt;&amp;nbsp; - call the subroutine and pass that id_variable as a parameter to the subroutine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have very limited experience with subroutines, but I think there's nothing much to it, it's basically just a script.&lt;/P&gt;&lt;P&gt;Do you know of any pitfalls I have to keep in mind (like any customary script_commands that will NOT work inside a subroutine)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DataNibbler&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think that's better.&lt;/P&gt;&lt;P&gt;Is there&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Nov 2013 11:35:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Building-a-FOR-NEXT-loop-based-on-Row-nrs/m-p/492776#M688723</guid>
      <dc:creator>datanibbler</dc:creator>
      <dc:date>2013-11-07T11:35:37Z</dc:date>
    </item>
    <item>
      <title>Re: Building a FOR...NEXT loop based on Row_nrs.</title>
      <link>https://community.qlik.com/t5/QlikView/Building-a-FOR-NEXT-loop-based-on-Row-nrs/m-p/492777#M688724</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;I thought I was now underway - I would first develop the code to - still for ONE employee - take the data RESIDENT from my base_load and via SQL from the second database_table - but now I am stopped by a thing that should actually be very simple - the way big projects often fail because of very little things...&lt;/P&gt;&lt;P&gt;=&amp;gt; I still cannot seem to define (or rather, I cannot check that I have successfully defined) a variable in the script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - I have a RESIDENT LOAD now that&amp;nbsp; loads just one record, for one employee&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - In the second table, I cannot count on the row_nrs being the same, so I have to filter that second LOAD using&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; the emp_id.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; =&amp;gt; To that end I have to somehow put the emp_id (which is in a field in that one loaded record) in a variable.&lt;/P&gt;&lt;P&gt;&amp;lt;=&amp;gt; Using the usual syntax with LET, I get no error, but I cannot see that variable on GUI-level - and I don't trust in its existence if I cannot see it...&lt;/P&gt;&lt;P&gt;Can you tell me what I am doing wrong there?&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DataNibbler&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P.S.: OK, I have it - it's awesome how reading up in the help_file often helps - sometimes combined with some guessing at what could be the right keyword to look for - in this case, the PEEK() function helped: In this scenario, I just loaded only one record, so I don't have to specify anything else, just the field_name.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Nov 2013 11:55:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Building-a-FOR-NEXT-loop-based-on-Row-nrs/m-p/492777#M688724</guid>
      <dc:creator>datanibbler</dc:creator>
      <dc:date>2013-11-07T11:55:58Z</dc:date>
    </item>
  </channel>
</rss>

