<?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 Problems with a variable in macro script. in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Problems-with-a-variable-in-macro-script/m-p/289696#M578845</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the following problem:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for P=0 to NoOfRows('Pol1')-1&lt;BR /&gt;LET vPOLICY_ID = chr(39)&amp;amp;Peek('POLICY_ID',$(P),Pol1)&amp;amp;chr(39);&lt;/P&gt;&lt;P&gt;Pol2:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Load "POLICY_ID" as POLICY_ID2,&lt;BR /&gt;SQL select POLICY_ID, ANNEX_ID, COVER_TYPE, INSR_TYPE&lt;BR /&gt;FROM "INSIS_OMN"."GEN_RISK_COVERED"&lt;/P&gt;&lt;P&gt;where POLICY_ID=$(vPOLICY_ID);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NEXT P&lt;/P&gt;&lt;P&gt;---------------------------------------------------&lt;/P&gt;&lt;P&gt;The problem is that at the first P=0, my peek function is working and my vPOLICY_ID variable gets the content of Peek('POLICY_ID',$(P),Pol1)&lt;/P&gt;&lt;P&gt;But after NEXT P statement, P takes the value 1, and my variable vPOLICY_ID becomes NULL. This happens for each P different with 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that my "Pol1" table has a lot of data inside.&lt;/P&gt;&lt;P&gt;I have tried not to use P for peek, and to give 0,1,2... instead of $(P) and my peek function works fine...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone detects where is the problem?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Silviu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Feb 2012 13:51:45 GMT</pubDate>
    <dc:creator />
    <dc:date>2012-02-16T13:51:45Z</dc:date>
    <item>
      <title>Problems with a variable in macro script.</title>
      <link>https://community.qlik.com/t5/QlikView/Problems-with-a-variable-in-macro-script/m-p/289696#M578845</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the following problem:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for P=0 to NoOfRows('Pol1')-1&lt;BR /&gt;LET vPOLICY_ID = chr(39)&amp;amp;Peek('POLICY_ID',$(P),Pol1)&amp;amp;chr(39);&lt;/P&gt;&lt;P&gt;Pol2:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Load "POLICY_ID" as POLICY_ID2,&lt;BR /&gt;SQL select POLICY_ID, ANNEX_ID, COVER_TYPE, INSR_TYPE&lt;BR /&gt;FROM "INSIS_OMN"."GEN_RISK_COVERED"&lt;/P&gt;&lt;P&gt;where POLICY_ID=$(vPOLICY_ID);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NEXT P&lt;/P&gt;&lt;P&gt;---------------------------------------------------&lt;/P&gt;&lt;P&gt;The problem is that at the first P=0, my peek function is working and my vPOLICY_ID variable gets the content of Peek('POLICY_ID',$(P),Pol1)&lt;/P&gt;&lt;P&gt;But after NEXT P statement, P takes the value 1, and my variable vPOLICY_ID becomes NULL. This happens for each P different with 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that my "Pol1" table has a lot of data inside.&lt;/P&gt;&lt;P&gt;I have tried not to use P for peek, and to give 0,1,2... instead of $(P) and my peek function works fine...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone detects where is the problem?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Silviu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Feb 2012 13:51:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problems-with-a-variable-in-macro-script/m-p/289696#M578845</guid>
      <dc:creator />
      <dc:date>2012-02-16T13:51:45Z</dc:date>
    </item>
    <item>
      <title>Problems with a variable in macro script.</title>
      <link>https://community.qlik.com/t5/QlikView/Problems-with-a-variable-in-macro-script/m-p/289697#M578846</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Silviu,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;code like you posted above worked just fine at my side (with my, different table data of course):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for P=0 to NoOfRows('Pol1')-1&lt;/P&gt;&lt;P&gt;LET vPOLICY_ID = chr(39)&amp;amp;Peek('POLICY_ID',$(P),'Pol1')&amp;amp;chr(39);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NEXT P&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that I enclosed the table name in single quotes (third parameter to the peek function), not sure if that is causing the problem, but could do.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Feb 2012 14:39:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problems-with-a-variable-in-macro-script/m-p/289697#M578846</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-02-16T14:39:09Z</dc:date>
    </item>
    <item>
      <title>Problems with a variable in macro script.</title>
      <link>https://community.qlik.com/t5/QlikView/Problems-with-a-variable-in-macro-script/m-p/289698#M578847</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; I have solved the problem.&lt;/P&gt;&lt;P&gt;The table name in function PEEK must be without ''.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Silviu.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Feb 2012 14:54:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problems-with-a-variable-in-macro-script/m-p/289698#M578847</guid>
      <dc:creator />
      <dc:date>2012-02-16T14:54:48Z</dc:date>
    </item>
  </channel>
</rss>

