<?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 problem with variable in for each loop in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/problem-with-variable-in-for-each-loop/m-p/154977#M31394</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;my issue is to load data from differenz companies dynamically. The exisiting company names can be loaded from the data source.&lt;/P&gt;&lt;P&gt;Then I write all the company names into one field, which I wanted to use as variable for the "for each..next" loop.&lt;/P&gt;&lt;P&gt;But my variable seems to be wrong.&lt;/P&gt;&lt;P&gt;See my code below, which is not working:&lt;/P&gt;&lt;P style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;B&gt;unqualify&lt;/B&gt; *;&lt;/P&gt;&lt;P style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;/P&gt;&lt;P style="font-style: italic; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none"&gt;Companies:&lt;/P&gt;&lt;P style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;B&gt;LOAD&lt;/B&gt; Name,&lt;/P&gt;&lt;P style="line-height: normal; text-indent: 35.4pt; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;autonumber(Name) &lt;B&gt;as&lt;/B&gt; Linenumber,&lt;/P&gt;&lt;P style="line-height: normal; text-indent: 35.4pt; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;'1' &lt;B&gt;as&lt;/B&gt; Gruppierung;&lt;/P&gt;&lt;P style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;B&gt;SQL&lt;/B&gt; &lt;B&gt;SELECT&lt;/B&gt; Name&lt;/P&gt;&lt;P style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;B&gt;FROM&lt;/B&gt; "Database".dbo.Company;&lt;/P&gt;&lt;P style="font-style: italic; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none"&gt;&lt;/P&gt;&lt;P style="font-style: italic; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none"&gt;Temp:&lt;/P&gt;&lt;P style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;B&gt;LOAD&lt;/B&gt; Gruppierung, concat(Name, ',') &lt;B&gt;AS&lt;/B&gt; Namensliste &lt;B&gt;resident&lt;/B&gt; Companies &lt;B&gt;GROUP&lt;/B&gt; &lt;B&gt;BY&lt;/B&gt; Gruppierung;&lt;/P&gt;&lt;P style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;/P&gt;&lt;P style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;B&gt;LET&lt;/B&gt; currField = 'Namensliste';&lt;/P&gt;&lt;P style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;B&gt;LET&lt;/B&gt; vCOMPANIES= FieldValue(&lt;B&gt;&lt;I&gt;'$(currField)'&lt;/I&gt;&lt;/B&gt;, 1);&lt;/P&gt;&lt;P style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;/P&gt;&lt;P style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;B&gt;unqualify&lt;/B&gt;*;&lt;/P&gt;&lt;P style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;/P&gt;&lt;P style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;B&gt;FOR&lt;/B&gt; EACH vCOMPANIES in &lt;B&gt;&lt;I&gt;$(vCOMPANIES)&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P style="font-style: italic; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-indent: 35.4pt"&gt;Customer:&lt;/P&gt;&lt;P style="line-height: normal; text-indent: 35.4pt; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;B&gt;LOAD&lt;/B&gt;&lt;/P&gt;&lt;P style="line-height: normal; text-indent: 35.4pt; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;B&gt;&lt;I&gt;'$(vCOMPANIES)'&lt;/I&gt;&lt;/B&gt; &lt;B&gt;as&lt;/B&gt; Company,&lt;/P&gt;&lt;P style="line-height: normal; text-indent: 35.4pt; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;"No_",&lt;/P&gt;&lt;P style="line-height: normal; text-indent: 35.4pt; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;Name;&lt;/P&gt;&lt;P style="line-height: normal; text-indent: 35.4pt; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;B&gt;SQL&lt;/B&gt; &lt;B&gt;SELECT&lt;/B&gt; *&lt;/P&gt;&lt;P style="line-height: normal; text-indent: 35.4pt; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;B&gt;FROM&lt;/B&gt; "Database".dbo."&lt;B&gt;&lt;I&gt;$(vCOMPANIES)&lt;/I&gt;&lt;/B&gt;$Customer";&lt;/P&gt;&lt;P style="line-height: normal; text-indent: 35.4pt; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;B&gt;store&lt;/B&gt; Customer &lt;B&gt;into&lt;/B&gt; . /qvd/Customer_&lt;B&gt;&lt;I&gt;$(vCOMPANIES)&lt;/I&gt;&lt;/B&gt;.qvd;&lt;/P&gt;&lt;P style="font-weight: bold; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none"&gt;NEXT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I fill the vCOMPANIES variable manually like this (&lt;B&gt;&lt;/B&gt;&lt;/P&gt;&lt;P style="font-weight: bold"&gt;SET&lt;/P&gt;&lt;B&gt;&lt;/B&gt;&lt;P style="font-weight: bold"&gt;&lt;/P&gt;vCOMPANIES='Company XX','Company YY' ) it works. The only difference are the ' ' in the string. &lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;But I need to load the companies dynamically from the source db.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Aug 2010 16:04:07 GMT</pubDate>
    <dc:creator />
    <dc:date>2010-08-10T16:04:07Z</dc:date>
    <item>
      <title>problem with variable in for each loop</title>
      <link>https://community.qlik.com/t5/QlikView/problem-with-variable-in-for-each-loop/m-p/154977#M31394</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;my issue is to load data from differenz companies dynamically. The exisiting company names can be loaded from the data source.&lt;/P&gt;&lt;P&gt;Then I write all the company names into one field, which I wanted to use as variable for the "for each..next" loop.&lt;/P&gt;&lt;P&gt;But my variable seems to be wrong.&lt;/P&gt;&lt;P&gt;See my code below, which is not working:&lt;/P&gt;&lt;P style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;B&gt;unqualify&lt;/B&gt; *;&lt;/P&gt;&lt;P style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;/P&gt;&lt;P style="font-style: italic; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none"&gt;Companies:&lt;/P&gt;&lt;P style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;B&gt;LOAD&lt;/B&gt; Name,&lt;/P&gt;&lt;P style="line-height: normal; text-indent: 35.4pt; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;autonumber(Name) &lt;B&gt;as&lt;/B&gt; Linenumber,&lt;/P&gt;&lt;P style="line-height: normal; text-indent: 35.4pt; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;'1' &lt;B&gt;as&lt;/B&gt; Gruppierung;&lt;/P&gt;&lt;P style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;B&gt;SQL&lt;/B&gt; &lt;B&gt;SELECT&lt;/B&gt; Name&lt;/P&gt;&lt;P style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;B&gt;FROM&lt;/B&gt; "Database".dbo.Company;&lt;/P&gt;&lt;P style="font-style: italic; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none"&gt;&lt;/P&gt;&lt;P style="font-style: italic; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none"&gt;Temp:&lt;/P&gt;&lt;P style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;B&gt;LOAD&lt;/B&gt; Gruppierung, concat(Name, ',') &lt;B&gt;AS&lt;/B&gt; Namensliste &lt;B&gt;resident&lt;/B&gt; Companies &lt;B&gt;GROUP&lt;/B&gt; &lt;B&gt;BY&lt;/B&gt; Gruppierung;&lt;/P&gt;&lt;P style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;/P&gt;&lt;P style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;B&gt;LET&lt;/B&gt; currField = 'Namensliste';&lt;/P&gt;&lt;P style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;B&gt;LET&lt;/B&gt; vCOMPANIES= FieldValue(&lt;B&gt;&lt;I&gt;'$(currField)'&lt;/I&gt;&lt;/B&gt;, 1);&lt;/P&gt;&lt;P style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;/P&gt;&lt;P style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;B&gt;unqualify&lt;/B&gt;*;&lt;/P&gt;&lt;P style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;/P&gt;&lt;P style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;B&gt;FOR&lt;/B&gt; EACH vCOMPANIES in &lt;B&gt;&lt;I&gt;$(vCOMPANIES)&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P style="font-style: italic; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none; text-indent: 35.4pt"&gt;Customer:&lt;/P&gt;&lt;P style="line-height: normal; text-indent: 35.4pt; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;B&gt;LOAD&lt;/B&gt;&lt;/P&gt;&lt;P style="line-height: normal; text-indent: 35.4pt; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;B&gt;&lt;I&gt;'$(vCOMPANIES)'&lt;/I&gt;&lt;/B&gt; &lt;B&gt;as&lt;/B&gt; Company,&lt;/P&gt;&lt;P style="line-height: normal; text-indent: 35.4pt; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;"No_",&lt;/P&gt;&lt;P style="line-height: normal; text-indent: 35.4pt; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;Name;&lt;/P&gt;&lt;P style="line-height: normal; text-indent: 35.4pt; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;B&gt;SQL&lt;/B&gt; &lt;B&gt;SELECT&lt;/B&gt; *&lt;/P&gt;&lt;P style="line-height: normal; text-indent: 35.4pt; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;B&gt;FROM&lt;/B&gt; "Database".dbo."&lt;B&gt;&lt;I&gt;$(vCOMPANIES)&lt;/I&gt;&lt;/B&gt;$Customer";&lt;/P&gt;&lt;P style="line-height: normal; text-indent: 35.4pt; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;&lt;B&gt;store&lt;/B&gt; Customer &lt;B&gt;into&lt;/B&gt; . /qvd/Customer_&lt;B&gt;&lt;I&gt;$(vCOMPANIES)&lt;/I&gt;&lt;/B&gt;.qvd;&lt;/P&gt;&lt;P style="font-weight: bold; line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none"&gt;NEXT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I fill the vCOMPANIES variable manually like this (&lt;B&gt;&lt;/B&gt;&lt;/P&gt;&lt;P style="font-weight: bold"&gt;SET&lt;/P&gt;&lt;B&gt;&lt;/B&gt;&lt;P style="font-weight: bold"&gt;&lt;/P&gt;vCOMPANIES='Company XX','Company YY' ) it works. The only difference are the ' ' in the string. &lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;But I need to load the companies dynamically from the source db.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Aug 2010 16:04:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/problem-with-variable-in-for-each-loop/m-p/154977#M31394</guid>
      <dc:creator />
      <dc:date>2010-08-10T16:04:07Z</dc:date>
    </item>
    <item>
      <title>problem with variable in for each loop</title>
      <link>https://community.qlik.com/t5/QlikView/problem-with-variable-in-for-each-loop/m-p/154978#M31395</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You got it right, the only difference is apostrophe (') or chr(39), try adding it like this:&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;"&gt;&lt;B&gt;LOAD&lt;/B&gt; Gruppierung, concat(chr(39)&amp;amp;Name&amp;amp;chr(39), ',') &lt;B&gt;AS&lt;/B&gt; Namensliste &lt;B&gt;resident&lt;/B&gt; Companies &lt;B&gt;GROUP&lt;/B&gt; &lt;B&gt;BY&lt;/B&gt; Gruppierung;&lt;/P&gt;&lt;P style="line-height:normal;margin:0cm 0cm 0pt;"&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Apr 2011 13:15:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/problem-with-variable-in-for-each-loop/m-p/154978#M31395</guid>
      <dc:creator>jacekvsp</dc:creator>
      <dc:date>2011-04-21T13:15:04Z</dc:date>
    </item>
  </channel>
</rss>

