<?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: Loading Data in a For loop in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Loading-Data-in-a-For-loop/m-p/1676329#M51414</link>
    <description>&lt;P&gt;I modified my original loop after noticing a flaw where the inner loop was not needed.&amp;nbsp; This runs but is still so slow as to be unusable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//No need to link records if there is no startDateEffective.&lt;BR /&gt;OrdTemp:&lt;BR /&gt;NoConcatenate&lt;BR /&gt;Load&lt;BR /&gt;*&lt;BR /&gt;Resident Order_Temp4&lt;BR /&gt;WHERE IsNull(startDateEffective) = 0;&lt;/P&gt;&lt;P&gt;//Get the count of rows&lt;BR /&gt;LET numOrderRows = NoOfRows('OrdTemp');&lt;/P&gt;&lt;P&gt;//Loop through all the order rows&lt;BR /&gt;FOR i = 0 to $(numOrderRows)-1&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Let vUniqueId = Peek('uniqueId',$(i),'OrdTemp');&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Let vStartDate = Num(Date(Floor(Peek('startDateEffective',$(i),'OrdTemp'))));&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Let vEndDate = Num(Date(Floor(Peek('endDateEffective',$(i),'OrdTemp'))));&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;IF $(i)=0 THEN&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;NoConcatenate tCal:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;Load&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;DISTINCT&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;masterCalDateKey,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;'$(vUniqueId)' AS uniqueId,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;'Start Date Effective' AS dateType&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;Resident DIM_MasterCalendar&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;Where&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;masterCalDateKey = $(vStartDate) OR //Need to include the actual startDateEffective&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;(masterCalDateKey &amp;gt; $(vStartDate) AND masterCalDateKey &amp;lt;= $(vEndDate) AND&amp;nbsp; masterCalFirstDayofFiscalMonthFlag = 1) //Need to include all the month beginning dates&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;ELSE&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;Concatenate(tCal)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;Load&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;DISTINCT&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;masterCalDateKey,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;'$(vUniqueId)' AS uniqueId,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;'Start Date Effective' AS dateType&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;Resident DIM_MasterCalendar&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;Where&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;masterCalDateKey = $(vStartDate) OR //Need to include the actual startDateEffective&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;(masterCalDateKey &amp;gt; $(vStartDate) AND masterCalDateKey &amp;lt;= $(vEndDate) AND masterCalFirstDayofFiscalMonthFlag = 1) //Need to include all the month beginning dates&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;End If&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;//Get the row count for the tCal table&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;//LET numCalRows = NoOfRows('tCal');&lt;/P&gt;&lt;P&gt;Next;&lt;/P&gt;&lt;P&gt;Concatenate(MasterDateLink)&lt;BR /&gt;LOAD&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;uniqueId,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;masterCalDateKey,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;dateType&lt;BR /&gt;Resident tCal;&lt;BR /&gt;&lt;BR /&gt;Drop Table tCal;&lt;/P&gt;</description>
    <pubDate>Mon, 17 Feb 2020 16:14:49 GMT</pubDate>
    <dc:creator>FMDF</dc:creator>
    <dc:date>2020-02-17T16:14:49Z</dc:date>
    <item>
      <title>Loading Data in a For loop</title>
      <link>https://community.qlik.com/t5/App-Development/Loading-Data-in-a-For-loop/m-p/1675420#M51298</link>
      <description>&lt;P&gt;I have order records that need to map on a chart.&amp;nbsp; There is a start and end date for each order line.&amp;nbsp; I need to create a row in a DateLink table for each month that the order line is open.&lt;/P&gt;&lt;P&gt;In my master calendar, I have a flag that tells me what the first day of the fiscal month is.&lt;/P&gt;&lt;P&gt;I only want to include the actual start date and then all "first day of fiscal month" values for each month.&amp;nbsp; This will allow me to map how I want later.&lt;/P&gt;&lt;P&gt;The first time through the loop IT WORKS.&amp;nbsp; The second time it fails with an error message that makes zero sense based on the code.&lt;/P&gt;&lt;P&gt;NoConcatenate OrdTemp:&lt;BR /&gt;Load&lt;BR /&gt;*&lt;BR /&gt;Resident Order_Temp4&lt;BR /&gt;WHERE IsNull(startDateEffective) = 0;&lt;/P&gt;&lt;P&gt;//Get the count of rows&lt;BR /&gt;LET numOrderRows = NoOfRows('OrdTemp');&lt;/P&gt;&lt;P&gt;//Loop through all the order rows&lt;BR /&gt;FOR i = 0 to $(numOrderRows)-1&lt;BR /&gt;Let vUniqueId = Peek('uniqueId',$(i),'OrdTemp');&lt;BR /&gt;Let vStartDate = Num(Date(Floor(Peek('startDateEffective',$(i),'OrdTemp'))));&lt;BR /&gt;Let vEndDate = Num(Date(Floor(Peek('endDateEffective',$(i),'OrdTemp'))));&lt;BR /&gt;&lt;BR /&gt;NoConcatenate tCal:&amp;nbsp; /////THIS IS THE LINE THAT FAILS THE 2ND TIME THRU THE LOOP.&amp;nbsp; ERROR BELOW.&lt;BR /&gt;Load&lt;BR /&gt;DISTINCT&lt;BR /&gt;masterCalDateKey&lt;BR /&gt;Resident DIM_MasterCalendar&lt;BR /&gt;Where&lt;BR /&gt;masterCalDateKey = $(vStartDate) OR //Need to include the actual startDateEffective&lt;BR /&gt;(masterCalDateKey &amp;gt; $(vStartDate) AND masterCalDateKey &amp;lt;= $(vEndDate) AND masterCalFirstDayofFiscalMonthFlag = 1) //Need to include all the month beginning dates&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;//Get the row count for the tCal table&lt;BR /&gt;LET numCalRows = NoOfRows('tCal');&lt;BR /&gt;&lt;BR /&gt;//Loop thru the calendar records&lt;BR /&gt;FOR j = 0 to $(numCalRows)-1&lt;BR /&gt;&lt;BR /&gt;//Get the next date key to add to the date link table.&lt;BR /&gt;vMasterCalDate = Peek('masterCalDateKey',$(j),'tCal');&lt;BR /&gt;&lt;BR /&gt;Concatenate(MasterDateLink)&lt;BR /&gt;LOAD&lt;BR /&gt;$(vUniqueId) AS uniqueId,&lt;BR /&gt;$(vMasterCalDate) AS masterCalDateKey,&lt;BR /&gt;'Start Date Effective' AS dateType&lt;BR /&gt;;&lt;BR /&gt;Next;&lt;BR /&gt;&lt;BR /&gt;Drop Table tCal;&lt;BR /&gt;Next;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the error:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Field 'USOrderDetail' not found: tCal1: Load DISTINCT masterCalDateKey Resident DIM_MasterCalendar Where masterCalDateKey = 38966 OR (masterCalDateKey &amp;gt; 38966 AND masterCalDateKey &amp;lt;= 39247 AND masterCalFirstDayofFiscalMonthFlag = 1) //Need to include all the month beginning dates&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't even reference a field called "USOrderDetail" in this loop.&amp;nbsp; Ever.&amp;nbsp; I am completely stuck.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 19:07:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Loading-Data-in-a-For-loop/m-p/1675420#M51298</guid>
      <dc:creator>FMDF</dc:creator>
      <dc:date>2024-11-16T19:07:12Z</dc:date>
    </item>
    <item>
      <title>Re: Loading Data in a For loop</title>
      <link>https://community.qlik.com/t5/App-Development/Loading-Data-in-a-For-loop/m-p/1675443#M51302</link>
      <description>&lt;P&gt;I believe NoConcatenate should go before the load statement, not the table name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;tCal:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;NoConcatenate Load&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2020 16:28:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Loading-Data-in-a-For-loop/m-p/1675443#M51302</guid>
      <dc:creator>lorenzoconforti</dc:creator>
      <dc:date>2020-02-13T16:28:40Z</dc:date>
    </item>
    <item>
      <title>Re: Loading Data in a For loop</title>
      <link>https://community.qlik.com/t5/App-Development/Loading-Data-in-a-For-loop/m-p/1675446#M51303</link>
      <description>&lt;P&gt;I have NoConcatenate in front of the table name all over my scripts and they work fine.&lt;/P&gt;&lt;P&gt;The first time through the loop it works.&lt;/P&gt;&lt;P&gt;It's the second time through that it is throwing that nonsense error.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2020 16:31:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Loading-Data-in-a-For-loop/m-p/1675446#M51303</guid>
      <dc:creator>FMDF</dc:creator>
      <dc:date>2020-02-13T16:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: Loading Data in a For loop</title>
      <link>https://community.qlik.com/t5/App-Development/Loading-Data-in-a-For-loop/m-p/1675460#M51307</link>
      <description>&lt;P&gt;Moving the NoConcatenate after the table name did not solve the problem.&amp;nbsp; Same error is coming up.&lt;/P&gt;&lt;P&gt;There is no logic to not finding a column name that isn't even referenced.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2020 16:55:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Loading-Data-in-a-For-loop/m-p/1675460#M51307</guid>
      <dc:creator>FMDF</dc:creator>
      <dc:date>2020-02-13T16:55:20Z</dc:date>
    </item>
    <item>
      <title>Re: Loading Data in a For loop</title>
      <link>https://community.qlik.com/t5/App-Development/Loading-Data-in-a-For-loop/m-p/1675462#M51308</link>
      <description>&lt;P&gt;it does look strange&lt;/P&gt;&lt;P&gt;Are you sure that during the first pass the script works as expected? I understand it doesn't give error, but does it produce what you are looking for during the first pass?&lt;/P&gt;&lt;P&gt;Can you share this application? Can you post the a picture of the Data Model Viewer?&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2020 17:04:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Loading-Data-in-a-For-loop/m-p/1675462#M51308</guid>
      <dc:creator>lorenzoconforti</dc:creator>
      <dc:date>2020-02-13T17:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: Loading Data in a For loop</title>
      <link>https://community.qlik.com/t5/App-Development/Loading-Data-in-a-For-loop/m-p/1675481#M51314</link>
      <description>&lt;P&gt;Please post the script log.&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2020 18:11:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Loading-Data-in-a-For-loop/m-p/1675481#M51314</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2020-02-13T18:11:24Z</dc:date>
    </item>
    <item>
      <title>Re: Loading Data in a For loop</title>
      <link>https://community.qlik.com/t5/App-Development/Loading-Data-in-a-For-loop/m-p/1675502#M51325</link>
      <description>&lt;P&gt;Actually, I wrote the data out to a qvd to debug.&lt;/P&gt;&lt;P&gt;It is not doing the Concatenate to MasterDateLink at all on the first pass...it just doesn't post an error.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2020 18:51:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Loading-Data-in-a-For-loop/m-p/1675502#M51325</guid>
      <dc:creator>FMDF</dc:creator>
      <dc:date>2020-02-13T18:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: Loading Data in a For loop</title>
      <link>https://community.qlik.com/t5/App-Development/Loading-Data-in-a-For-loop/m-p/1675617#M51343</link>
      <description>&lt;P&gt;That makes sense as there is no data source in that Load statement.&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 01:09:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Loading-Data-in-a-For-loop/m-p/1675617#M51343</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2020-02-14T01:09:42Z</dc:date>
    </item>
    <item>
      <title>Re: Loading Data in a For loop</title>
      <link>https://community.qlik.com/t5/App-Development/Loading-Data-in-a-For-loop/m-p/1675628#M51345</link>
      <description>&lt;P&gt;There doesn't need to be a data source in the load statement.&amp;nbsp; I was missing the AutoGenerate 1 at the end and I was missing single quotes around the first column.&amp;nbsp; So it took the data as a column name instead of a literal.&lt;/P&gt;&lt;P&gt;I will post the correction tomorrow since it may help others in the future.&amp;nbsp; While I believe it works now, the performance is awful.&amp;nbsp; I will have to think of a new approach.&lt;/P&gt;&lt;P&gt;Cheers &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 03:02:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Loading-Data-in-a-For-loop/m-p/1675628#M51345</guid>
      <dc:creator>FMDF</dc:creator>
      <dc:date>2020-02-14T03:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: Loading Data in a For loop</title>
      <link>https://community.qlik.com/t5/App-Development/Loading-Data-in-a-For-loop/m-p/1675630#M51346</link>
      <description>&lt;P&gt;AutoGenerate is a data source &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Looping over the rows of a table is generally very slow.&amp;nbsp; You might do better with something like:&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT face="courier new,courier"&gt;Keys:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN class="s1"&gt;LOAD&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN class="s2"&gt;OrderId&lt;/SPAN&gt;,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN class="s2"&gt;masterCalDateKey&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN class="s1"&gt;Where&lt;/SPAN&gt; &lt;SPAN class="s2"&gt;masterCalDateKey&lt;/SPAN&gt; = &lt;SPAN class="s2"&gt;StartDate&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN class="s1"&gt;or&lt;/SPAN&gt; &lt;SPAN class="s1"&gt;Lookup&lt;/SPAN&gt;('masterCalFirstDayofFiscalMonthFlag', 'masterCalDateKey', &lt;SPAN class="s2"&gt;masterCalDateKey&lt;/SPAN&gt;, 'Calendar') = 1 &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;; &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN class="s1"&gt;LOAD&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN class="s2"&gt;OrderId&lt;/SPAN&gt;,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN class="s2"&gt;StartDate&lt;/SPAN&gt;,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN class="s1"&gt;Date&lt;/SPAN&gt;(&lt;SPAN class="s2"&gt;StartDate&lt;/SPAN&gt; + &lt;SPAN class="s1"&gt;IterNo&lt;/SPAN&gt;() - 1) &lt;SPAN class="s1"&gt;as&lt;/SPAN&gt; &lt;SPAN class="s2"&gt;masterCalDateKey&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN class="s1"&gt;Resident&lt;/SPAN&gt; Orders&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN class="s1"&gt;While&lt;/SPAN&gt; &lt;SPAN class="s2"&gt;StartDate&lt;/SPAN&gt; + &lt;SPAN class="s1"&gt;IterNo&lt;/SPAN&gt;() - 1 &amp;lt;= &lt;SPAN class="s2"&gt;EndDate&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;Lookup() can be kinda slow as well. If it's the case that it's too slow, you can replace the lookup with an ApplyMap like this:&lt;/P&gt;&lt;P class="p1"&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;SPAN class="s1"&gt;MapFirstDay:&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="s2"&gt;Mapping&lt;/SPAN&gt;&lt;SPAN class="s1"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="s2"&gt;LOAD&lt;/SPAN&gt; masterCalDateKey&lt;SPAN class="s1"&gt;,&lt;BR /&gt;&lt;/SPAN&gt;masterCalFirstDayofFiscalMonthFlag&lt;SPAN class="s1"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="s2"&gt;Resident&lt;/SPAN&gt;&lt;SPAN class="s1"&gt; Calendar&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="s2"&gt;Where&lt;/SPAN&gt; masterCalFirstDayofFiscalMonthFlag&lt;/STRONG&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt; = 1&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;BR /&gt;Keys:&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="s2"&gt;LOAD&lt;/SPAN&gt;&lt;SPAN class="s1"&gt;&lt;BR /&gt;&lt;/SPAN&gt;OrderId&lt;SPAN class="s1"&gt;,&lt;BR /&gt;&lt;/SPAN&gt;masterCalDateKey&lt;SPAN class="s1"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="s2"&gt;Where&lt;/SPAN&gt; masterCalDateKey&lt;SPAN class="s1"&gt; = &lt;/SPAN&gt;StartDate&lt;SPAN class="s1"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="s2"&gt;or&lt;/SPAN&gt; &lt;STRONG&gt;&lt;SPAN class="s2"&gt;ApplyMap&lt;/SPAN&gt;&lt;SPAN class="s1"&gt;('MapFirstDay', &lt;/SPAN&gt;masterCalDateKey&lt;/STRONG&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;) = 1&lt;/STRONG&gt;&lt;BR /&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="s2"&gt;LOAD&lt;/SPAN&gt;&lt;SPAN class="s1"&gt;&lt;BR /&gt;&lt;/SPAN&gt;OrderId&lt;SPAN class="s1"&gt;,&lt;BR /&gt;&lt;/SPAN&gt;StartDate&lt;SPAN class="s1"&gt;,&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="s2"&gt;Date&lt;/SPAN&gt;&lt;SPAN class="s1"&gt;(&lt;/SPAN&gt;StartDate&lt;SPAN class="s1"&gt; + &lt;/SPAN&gt;&lt;SPAN class="s2"&gt;IterNo&lt;/SPAN&gt;&lt;SPAN class="s1"&gt;() - 1) &lt;/SPAN&gt;&lt;SPAN class="s2"&gt;as&lt;/SPAN&gt; masterCalDateKey&lt;SPAN class="s1"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="s2"&gt;Resident&lt;/SPAN&gt;&lt;SPAN class="s1"&gt; Orders&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="s2"&gt;While&lt;/SPAN&gt; StartDate&lt;SPAN class="s1"&gt; + &lt;/SPAN&gt;&lt;SPAN class="s2"&gt;IterNo&lt;/SPAN&gt;&lt;SPAN class="s1"&gt;() - 1 &amp;lt;= &lt;/SPAN&gt;EndDate&lt;SPAN class="s1"&gt;&lt;BR /&gt;; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="p1"&gt;-Rob&lt;BR /&gt;&lt;A href="http://masterssummit.com" target="_blank" rel="noopener"&gt;http://masterssummit.com&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://qlikviewcookbook.com" target="_blank" rel="noopener"&gt;http://qlikviewcookbook.com&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.easyqlik.com" target="_blank" rel="noopener"&gt;http://www.easyqlik.com&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 03:28:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Loading-Data-in-a-For-loop/m-p/1675630#M51346</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2020-02-14T03:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: Loading Data in a For loop</title>
      <link>https://community.qlik.com/t5/App-Development/Loading-Data-in-a-For-loop/m-p/1676329#M51414</link>
      <description>&lt;P&gt;I modified my original loop after noticing a flaw where the inner loop was not needed.&amp;nbsp; This runs but is still so slow as to be unusable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//No need to link records if there is no startDateEffective.&lt;BR /&gt;OrdTemp:&lt;BR /&gt;NoConcatenate&lt;BR /&gt;Load&lt;BR /&gt;*&lt;BR /&gt;Resident Order_Temp4&lt;BR /&gt;WHERE IsNull(startDateEffective) = 0;&lt;/P&gt;&lt;P&gt;//Get the count of rows&lt;BR /&gt;LET numOrderRows = NoOfRows('OrdTemp');&lt;/P&gt;&lt;P&gt;//Loop through all the order rows&lt;BR /&gt;FOR i = 0 to $(numOrderRows)-1&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Let vUniqueId = Peek('uniqueId',$(i),'OrdTemp');&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Let vStartDate = Num(Date(Floor(Peek('startDateEffective',$(i),'OrdTemp'))));&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Let vEndDate = Num(Date(Floor(Peek('endDateEffective',$(i),'OrdTemp'))));&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;IF $(i)=0 THEN&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;NoConcatenate tCal:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;Load&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;DISTINCT&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;masterCalDateKey,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;'$(vUniqueId)' AS uniqueId,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;'Start Date Effective' AS dateType&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;Resident DIM_MasterCalendar&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;Where&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;masterCalDateKey = $(vStartDate) OR //Need to include the actual startDateEffective&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;(masterCalDateKey &amp;gt; $(vStartDate) AND masterCalDateKey &amp;lt;= $(vEndDate) AND&amp;nbsp; masterCalFirstDayofFiscalMonthFlag = 1) //Need to include all the month beginning dates&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;ELSE&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;Concatenate(tCal)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;Load&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;DISTINCT&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;masterCalDateKey,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;'$(vUniqueId)' AS uniqueId,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;'Start Date Effective' AS dateType&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;Resident DIM_MasterCalendar&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;Where&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;masterCalDateKey = $(vStartDate) OR //Need to include the actual startDateEffective&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;(masterCalDateKey &amp;gt; $(vStartDate) AND masterCalDateKey &amp;lt;= $(vEndDate) AND masterCalFirstDayofFiscalMonthFlag = 1) //Need to include all the month beginning dates&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;End If&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;//Get the row count for the tCal table&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;//LET numCalRows = NoOfRows('tCal');&lt;/P&gt;&lt;P&gt;Next;&lt;/P&gt;&lt;P&gt;Concatenate(MasterDateLink)&lt;BR /&gt;LOAD&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;uniqueId,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;masterCalDateKey,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;dateType&lt;BR /&gt;Resident tCal;&lt;BR /&gt;&lt;BR /&gt;Drop Table tCal;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2020 16:14:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Loading-Data-in-a-For-loop/m-p/1676329#M51414</guid>
      <dc:creator>FMDF</dc:creator>
      <dc:date>2020-02-17T16:14:49Z</dc:date>
    </item>
  </channel>
</rss>

