<?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: Loops and scoping in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Loops-and-scoping/m-p/810005#M285917</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Christopher, I think your first observations is the correct one. The first time around that the engine encounters the peek() function, it will return a correct value because the third parameter is no parameter and peek() will fall back to the table that was most recently loaded, e.g. connections. Call it beginners luck.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Inbetween the first and the second loop, various other tables have been loaded, and now the peek() function won't find a field called 'Connection' in the table that was most recently loaded. &lt;EM&gt;Therefor, NULL shall be thy reward.&lt;/EM&gt; Unfortunately.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greengold, put single quotes around the third parameter and try again. It's all in the details (mostly in the (lack of) punctuation marks) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 16 Mar 2015 14:14:38 GMT</pubDate>
    <dc:creator>Peter_Cammaert</dc:creator>
    <dc:date>2015-03-16T14:14:38Z</dc:date>
    <item>
      <title>Loops and scoping</title>
      <link>https://community.qlik.com/t5/QlikView/Loops-and-scoping/m-p/810000#M285912</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there!&lt;/P&gt;&lt;P&gt;To put this straight I'm having a trouble with a table being extracted before for-looping. Table I am talking about get's extracted well but after the first iteration of for loop it get's lost and so do the data I need to work with in this loop.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My code looks like this:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;connections:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;LOAD Connection&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;FROM&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;C&gt;&lt;/C&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;(ooxml, embedded labels, table is Sheet1);&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;LET NumRows=NoOfRows('connections');&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;FOR conn = 1 to $(NumRows)&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LET conStr = Peek('Connection', $(conn), connections);&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; OLEDB CONNECT TO $(conStr) (XPassword is OEdObQVNHE);&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CALL loadData&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DISCONNECT;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;NEXT conn&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;store SoftwareResults into [$(vQvdPath)SoftwareResults.qvd]&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;(qvd);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically this is for extracting the same set of data from multiple connections. Extract procedure is defined in the other tab and is called 'loadData'.&lt;/P&gt;&lt;P&gt;I'm adding screenshots from debugger.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So why is the 'connections' table &amp;lt;null&amp;gt; after the first loop iteration? how to avoid this?&lt;BR /&gt;Thank you for your comments!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Mar 2015 13:24:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loops-and-scoping/m-p/810000#M285912</guid>
      <dc:creator />
      <dc:date>2015-03-16T13:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: Loops and scoping</title>
      <link>https://community.qlik.com/t5/QlikView/Loops-and-scoping/m-p/810001#M285913</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have been struggling with a peek that ended up trashing my Saturday morning (&lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/sad.png" /&gt;) that sounds familiar.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First observation I always find I have to put the table name in single quotes, but maybe that is just me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Second thing was I didn't have the table name initially and as I was also doing something with my key (that was a date, but equivalent of your Connection) in my sub (that was an equivalent of your loadData) it seemed to be resetting my list of values when it looped back around.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not sure if that helps or not. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Mar 2015 13:40:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loops-and-scoping/m-p/810001#M285913</guid>
      <dc:creator>chrismarlow</dc:creator>
      <dc:date>2015-03-16T13:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: Loops and scoping</title>
      <link>https://community.qlik.com/t5/QlikView/Loops-and-scoping/m-p/810002#M285914</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;no, peek works well, problem is that after first iteration pass table is null...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Mar 2015 13:47:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loops-and-scoping/m-p/810002#M285914</guid>
      <dc:creator />
      <dc:date>2015-03-16T13:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: Loops and scoping</title>
      <link>https://community.qlik.com/t5/QlikView/Loops-and-scoping/m-p/810003#M285915</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hmmm, despite that it does sound familiar. That is what I was seeing, abridged code;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="hitting AMNT_DATE.PNG" class="image-1 jive-image" src="/legacyfs/online/80838_hitting AMNT_DATE.PNG" style="width: 620px; height: 462px;" /&gt;&lt;BR /&gt;So before I added the table (3, as I say with single quotes) because I was doing something (2 with a separate table) to AMNT_DATE, I was then seeing null on second pass of my field AMNT_DATE (1) even though I could store 'dates' or stop the app and look at it &amp;amp; see that I had a set of dates.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Mar 2015 13:59:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loops-and-scoping/m-p/810003#M285915</guid>
      <dc:creator>chrismarlow</dc:creator>
      <dc:date>2015-03-16T13:59:44Z</dc:date>
    </item>
    <item>
      <title>Re: Loops and scoping</title>
      <link>https://community.qlik.com/t5/QlikView/Loops-and-scoping/m-p/810004#M285916</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sorry Christopher, I have tried single quotes on table name in peek and this corrects the problem. Connections table is no longer null.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another magic of qlik worked out...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Mar 2015 14:12:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loops-and-scoping/m-p/810004#M285916</guid>
      <dc:creator />
      <dc:date>2015-03-16T14:12:20Z</dc:date>
    </item>
    <item>
      <title>Re: Loops and scoping</title>
      <link>https://community.qlik.com/t5/QlikView/Loops-and-scoping/m-p/810005#M285917</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Christopher, I think your first observations is the correct one. The first time around that the engine encounters the peek() function, it will return a correct value because the third parameter is no parameter and peek() will fall back to the table that was most recently loaded, e.g. connections. Call it beginners luck.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Inbetween the first and the second loop, various other tables have been loaded, and now the peek() function won't find a field called 'Connection' in the table that was most recently loaded. &lt;EM&gt;Therefor, NULL shall be thy reward.&lt;/EM&gt; Unfortunately.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greengold, put single quotes around the third parameter and try again. It's all in the details (mostly in the (lack of) punctuation marks) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Mar 2015 14:14:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loops-and-scoping/m-p/810005#M285917</guid>
      <dc:creator>Peter_Cammaert</dc:creator>
      <dc:date>2015-03-16T14:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: Loops and scoping</title>
      <link>https://community.qlik.com/t5/QlikView/Loops-and-scoping/m-p/810006#M285918</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah. Thank you for the good explanation ... that makes sense now (which will make it easier to remember for next time &amp;amp; hopefully save my weekend!).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Mar 2015 14:25:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loops-and-scoping/m-p/810006#M285918</guid>
      <dc:creator>chrismarlow</dc:creator>
      <dc:date>2015-03-16T14:25:21Z</dc:date>
    </item>
  </channel>
</rss>

