<?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 For loop slows down, why? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/For-loop-slows-down-why/m-p/186766#M50733</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 use for .. next loop to go through one table row by row and I add with autogenerate line/lines if there is missing line.&lt;/P&gt;&lt;P&gt;This loop works quite fast when it is just started. I get about 20 rounds in minute. But after one or two hour, this loop is running very slow.&lt;/P&gt;&lt;P&gt;Then I get about 2 new lines in minute. This is 10x speed difference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And if I abort manually for... next loop and replace starting value from 1 to the value it was before aborting, then loop is running again normally.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Has someone else noticed this kind of slowliness with long running for .. next loops. And is there any solutions to fix this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Harri&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the for loop (sorry if the&lt;/P&gt;&lt;PRE ___default_attr="plain" class="jive_text_macro jive_macro_code" jivemacro="code"&gt;&lt;/PRE&gt;tagging is not working, i tried...)&lt;BR /&gt;&lt;BR /&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;for i=1 to NoOfRows('TR_Hist_Sorted')-1&lt;BR /&gt;&lt;BR /&gt;//read values from current row and store value from above to another variable&lt;BR /&gt;LET moment_before=$(ajankohta_nyt);&lt;BR /&gt;LET moment_now=PEEK('SMONTHENDKEY',$(i),'TR_Hist_Sorted');&lt;BR /&gt;&lt;BR /&gt;LET product_before='$(product_now)';&lt;BR /&gt;LET product_now=PEEK('S%%%ITEMKEY',$(i),'TR_Hist_Sorted');&lt;BR /&gt;&lt;BR /&gt;LET value_before='$(value_now)';&lt;BR /&gt;LET value_now=PEEK('SQTY_OH',$(i),'TR_Hist_Sorted');&lt;BR /&gt;&lt;BR /&gt;//calculate current row´s and row above time difference.&lt;BR /&gt;LET difference=$(moment_now)-$(moment_before);&lt;BR /&gt;&lt;BR /&gt;//if product is same, lets make missing rows with for next loop&lt;BR /&gt;// if time difference is 1 then this next loop is not done because we have 1 to 0 in loops definition&lt;BR /&gt;IF '$(product_now)'='$(product_before)' then&lt;BR /&gt; for adding_loop=1 to ($(difference)-1)&lt;BR /&gt; concatenate(TR_Hist_Sorted)&lt;BR /&gt; //lets build missing row with autogenerate&lt;BR /&gt; load&lt;BR /&gt; '$(product_now)' as S%%%ITEMKEY,&lt;BR /&gt; ($(moment_now))-($(adding_loop)) as SMONTHENDKEY,&lt;BR /&gt;&lt;BR /&gt; $(value_before) as SQTY_OH,&lt;BR /&gt; applymap('Month_Key_Map',($(moment_now))-($(adding_loop)),'N/A') as SMONTH_END_DATE&lt;BR /&gt; autogenerate(1);&lt;BR /&gt; next // now we have added one missing row for one product&lt;BR /&gt;end if // End of "is this same product"&lt;BR /&gt;next // next line in main table&lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 14 Jun 2010 07:34:45 GMT</pubDate>
    <dc:creator />
    <dc:date>2010-06-14T07:34:45Z</dc:date>
    <item>
      <title>For loop slows down, why?</title>
      <link>https://community.qlik.com/t5/QlikView/For-loop-slows-down-why/m-p/186766#M50733</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 use for .. next loop to go through one table row by row and I add with autogenerate line/lines if there is missing line.&lt;/P&gt;&lt;P&gt;This loop works quite fast when it is just started. I get about 20 rounds in minute. But after one or two hour, this loop is running very slow.&lt;/P&gt;&lt;P&gt;Then I get about 2 new lines in minute. This is 10x speed difference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And if I abort manually for... next loop and replace starting value from 1 to the value it was before aborting, then loop is running again normally.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Has someone else noticed this kind of slowliness with long running for .. next loops. And is there any solutions to fix this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Harri&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the for loop (sorry if the&lt;/P&gt;&lt;PRE ___default_attr="plain" class="jive_text_macro jive_macro_code" jivemacro="code"&gt;&lt;/PRE&gt;tagging is not working, i tried...)&lt;BR /&gt;&lt;BR /&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;for i=1 to NoOfRows('TR_Hist_Sorted')-1&lt;BR /&gt;&lt;BR /&gt;//read values from current row and store value from above to another variable&lt;BR /&gt;LET moment_before=$(ajankohta_nyt);&lt;BR /&gt;LET moment_now=PEEK('SMONTHENDKEY',$(i),'TR_Hist_Sorted');&lt;BR /&gt;&lt;BR /&gt;LET product_before='$(product_now)';&lt;BR /&gt;LET product_now=PEEK('S%%%ITEMKEY',$(i),'TR_Hist_Sorted');&lt;BR /&gt;&lt;BR /&gt;LET value_before='$(value_now)';&lt;BR /&gt;LET value_now=PEEK('SQTY_OH',$(i),'TR_Hist_Sorted');&lt;BR /&gt;&lt;BR /&gt;//calculate current row´s and row above time difference.&lt;BR /&gt;LET difference=$(moment_now)-$(moment_before);&lt;BR /&gt;&lt;BR /&gt;//if product is same, lets make missing rows with for next loop&lt;BR /&gt;// if time difference is 1 then this next loop is not done because we have 1 to 0 in loops definition&lt;BR /&gt;IF '$(product_now)'='$(product_before)' then&lt;BR /&gt; for adding_loop=1 to ($(difference)-1)&lt;BR /&gt; concatenate(TR_Hist_Sorted)&lt;BR /&gt; //lets build missing row with autogenerate&lt;BR /&gt; load&lt;BR /&gt; '$(product_now)' as S%%%ITEMKEY,&lt;BR /&gt; ($(moment_now))-($(adding_loop)) as SMONTHENDKEY,&lt;BR /&gt;&lt;BR /&gt; $(value_before) as SQTY_OH,&lt;BR /&gt; applymap('Month_Key_Map',($(moment_now))-($(adding_loop)),'N/A') as SMONTH_END_DATE&lt;BR /&gt; autogenerate(1);&lt;BR /&gt; next // now we have added one missing row for one product&lt;BR /&gt;end if // End of "is this same product"&lt;BR /&gt;next // next line in main table&lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Jun 2010 07:34:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/For-loop-slows-down-why/m-p/186766#M50733</guid>
      <dc:creator />
      <dc:date>2010-06-14T07:34:45Z</dc:date>
    </item>
    <item>
      <title>For loop slows down, why?</title>
      <link>https://community.qlik.com/t5/QlikView/For-loop-slows-down-why/m-p/186767#M50734</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;Maybe this is an idea to solve your problem without a loop.&lt;/P&gt;&lt;P&gt;Good luck!&lt;/P&gt;&lt;P&gt;Rainer&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Jun 2010 10:08:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/For-loop-slows-down-why/m-p/186767#M50734</guid>
      <dc:creator />
      <dc:date>2010-06-14T10:08:38Z</dc:date>
    </item>
  </channel>
</rss>

