<?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 AW:loop within LOAD in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/loop-within-LOAD/m-p/220253#M73185</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you John for your idea !&lt;/P&gt;&lt;P&gt;Can you please let me know, if there is any way of implementing loop within the LOAD (inter-record loop)?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 13 Jul 2010 11:29:11 GMT</pubDate>
    <dc:creator>tresB</dc:creator>
    <dc:date>2010-07-13T11:29:11Z</dc:date>
    <item>
      <title>loop within LOAD</title>
      <link>https://community.qlik.com/t5/QlikView/loop-within-LOAD/m-p/220249#M73181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I have two date fields (startdate and enddate). I want to calculate the number of Tuesdays between these dates (for every record)&lt;/P&gt;&lt;P&gt;within the script during load itself. I think the loop is needed to be used within the LOAD. Please help me out.....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jul 2010 05:45:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/loop-within-LOAD/m-p/220249#M73181</guid>
      <dc:creator>tresB</dc:creator>
      <dc:date>2010-07-12T05:45:33Z</dc:date>
    </item>
    <item>
      <title>AW:loop within LOAD</title>
      <link>https://community.qlik.com/t5/QlikView/loop-within-LOAD/m-p/220250#M73182</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;you can use a if-then-else statement:&lt;/P&gt;&lt;P&gt;If(Weekday(datefielt)=2,1,0) as CountTuesdays&lt;/P&gt;&lt;P&gt;and than use Sum(CountTuesdays)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jul 2010 08:19:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/loop-within-LOAD/m-p/220250#M73182</guid>
      <dc:creator>brenner_martina</dc:creator>
      <dc:date>2010-07-12T08:19:59Z</dc:date>
    </item>
    <item>
      <title>AW:loop within LOAD</title>
      <link>https://community.qlik.com/t5/QlikView/loop-within-LOAD/m-p/220251#M73183</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Martina, for your attention.&lt;/P&gt;&lt;P&gt;But what i want a little different. Let me explain once again.&lt;/P&gt;&lt;P&gt;two fields i have -- START_DATE and END_DATE. now i need to check(and count) if there is any Sunday in between these two dates. Logically I would require to run a loop for every record .&lt;/P&gt;&lt;P&gt;STAR_DATE END_DATE NO-OF SUNDAYS _between&lt;/P&gt;&lt;P&gt;10/10/2010 10/12/2010 ??&lt;/P&gt;&lt;P&gt;05/05/2010 06/07/2010 ??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please show me a way out.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jul 2010 09:03:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/loop-within-LOAD/m-p/220251#M73183</guid>
      <dc:creator>tresB</dc:creator>
      <dc:date>2010-07-12T09:03:18Z</dc:date>
    </item>
    <item>
      <title>AW:loop within LOAD</title>
      <link>https://community.qlik.com/t5/QlikView/loop-within-LOAD/m-p/220252#M73184</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm heading home so won't try to build the actual expression. But you can count weeks by just (END_DATE - START_DATE)/7. Then it's just a matter of adjusting the first and last week if necessary, based on what those days of the week are.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Jul 2010 02:06:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/loop-within-LOAD/m-p/220252#M73184</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-07-13T02:06:37Z</dc:date>
    </item>
    <item>
      <title>AW:loop within LOAD</title>
      <link>https://community.qlik.com/t5/QlikView/loop-within-LOAD/m-p/220253#M73185</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you John for your idea !&lt;/P&gt;&lt;P&gt;Can you please let me know, if there is any way of implementing loop within the LOAD (inter-record loop)?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Jul 2010 11:29:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/loop-within-LOAD/m-p/220253#M73185</guid>
      <dc:creator>tresB</dc:creator>
      <dc:date>2010-07-13T11:29:11Z</dc:date>
    </item>
    <item>
      <title>AW:loop within LOAD</title>
      <link>https://community.qlik.com/t5/QlikView/loop-within-LOAD/m-p/220254#M73186</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well... probably, but it would be much less efficient, and I'd have to study the exact syntax since I use loops so rarely. But maybe something along these lines:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;set count = number of rows in the table;&lt;BR /&gt;for i = 1 to count&lt;BR /&gt; set Tuesdays = 0&lt;BR /&gt; for date = (first Tuesday on or after START DATE) to (last Tuesday on or before END_DATE)&lt;BR /&gt; add 1 to Tuesdays&lt;BR /&gt; next&lt;BR /&gt; LEFT JOIN ([My Table])&lt;BR /&gt; LOAD fieldvalue('KeyField',$(i)), $(Tuesdays) as NumberOfTuesdays&lt;BR /&gt; AUTOGENERATE 1;&lt;BR /&gt;next&lt;/P&gt;&lt;P&gt;But yikes is that ugly. There's probably a more efficient loop, but a calculation is much faster.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Jul 2010 17:45:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/loop-within-LOAD/m-p/220254#M73186</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-07-13T17:45:57Z</dc:date>
    </item>
    <item>
      <title>AW:loop within LOAD</title>
      <link>https://community.qlik.com/t5/QlikView/loop-within-LOAD/m-p/220255#M73187</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="jive_text_macro jive_macro_quote" jivemacro="quote"&gt;&lt;BR /&gt;tresesco wrote:Can you please let me know, if there is any way of implementing loop within the LOAD (inter-record loop)?&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;John's calculation suggestion is probably the best way to address your original question. To answer your question re looping. The typical Qlikview method of looping within records is using WHILE and Iterno(). Here's a script that counts Sundays using that technique.&lt;/P&gt;&lt;P&gt;data:&lt;BR /&gt;LOAD * INLINE [&lt;BR /&gt;STAR_DATE, END_DATE&lt;BR /&gt;10/10/2010, 10/12/2010&lt;BR /&gt;05/05/2010, 06/07/2010&lt;BR /&gt;07/04/2010, 07/06/2010&lt;BR /&gt;07/05/2010, 07/06/2010&lt;BR /&gt;07/04/2010, 07/11/2010&lt;BR /&gt;07/04/2010, 07/12/2010&lt;BR /&gt;]&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;LEFT JOIN (data)&lt;BR /&gt;LOAD&lt;BR /&gt; STAR_DATE,&lt;BR /&gt; END_DATE,&lt;BR /&gt;sum(SundayCount) as SundayCount&lt;BR /&gt;GROUP By STAR_DATE, END_DATE&lt;BR /&gt;;&lt;BR /&gt;LOAD&lt;BR /&gt; STAR_DATE,&lt;BR /&gt; END_DATE,&lt;BR /&gt; if(Weekday(STAR_DATE + iterno()-1) = 'Sun', 1, 0) as SundayCount,&lt;BR /&gt; date(STAR_DATE + iterno()-1) as Date&lt;BR /&gt;RESIDENT data&lt;BR /&gt;WHILE STAR_DATE + iterno()-1 &amp;lt;= END_DATE&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Jul 2010 05:05:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/loop-within-LOAD/m-p/220255#M73187</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2010-07-14T05:05:32Z</dc:date>
    </item>
    <item>
      <title>AW:loop within LOAD</title>
      <link>https://community.qlik.com/t5/QlikView/loop-within-LOAD/m-p/220256#M73188</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot Rob and John ! Your codes are really helpful. I admire your logics.&lt;/P&gt;&lt;P&gt;Thanks ance again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Jul 2010 07:03:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/loop-within-LOAD/m-p/220256#M73188</guid>
      <dc:creator>tresB</dc:creator>
      <dc:date>2010-07-16T07:03:08Z</dc:date>
    </item>
  </channel>
</rss>

