<?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 Trouble using variable in the FOR EACH statement rather than a literal in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Trouble-using-variable-in-the-FOR-EACH-statement-rather-than-a/m-p/173464#M502593</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I missed the variable expansion in the for each line:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;FOR EACH vConvertCurrency IN &lt;B&gt;$(vCurrencyCodes)&lt;/B&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Hope that works.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 30 Aug 2010 09:00:12 GMT</pubDate>
    <dc:creator>Miguel_Angel_Baeyens</dc:creator>
    <dc:date>2010-08-30T09:00:12Z</dc:date>
    <item>
      <title>Trouble using variable in the FOR EACH statement rather than a literal</title>
      <link>https://community.qlik.com/t5/QlikView/Trouble-using-variable-in-the-FOR-EACH-statement-rather-than-a/m-p/173459#M502588</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We would like to substitute the value of the quoted currencies in the FOR EACH statement rather than having a 'closed' list&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FOR EACH vConvertCurrency IN 'AUD','USD','EUR' // Want to use variable read in from a table here&lt;/P&gt;&lt;P&gt;RawRate:&lt;/P&gt;&lt;P&gt;LOAD Replace(@1,'.','/') as Date,&lt;/P&gt;&lt;P&gt;'$(vConvertCurrency)' as Currency,&lt;/P&gt;&lt;P&gt;@2 as Rate&lt;/P&gt;&lt;P&gt;FROM&lt;/P&gt;&lt;P&gt;[http://www.oanda.com/currency/historical-rates?date_fmt=normal&amp;amp;date=$(vMaxDate)&amp;amp;date1=$(vMinDate)&amp;amp;exch=$(vBaseCurrency)&amp;amp;exch2=$(vBaseCurrency)&amp;amp;expr=$(vConvertCurrency)&amp;amp;expr2=$(vConvertCurrency)&amp;amp;margin_fixed=0&amp;amp;format=HTML&amp;amp;redirected=1]&lt;/P&gt;&lt;P&gt;(html, codepage is 1252, no labels, table is @1);&lt;/P&gt;&lt;P&gt;NEXT&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Aug 2010 08:44:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Trouble-using-variable-in-the-FOR-EACH-statement-rather-than-a/m-p/173459#M502588</guid>
      <dc:creator />
      <dc:date>2010-08-25T08:44:03Z</dc:date>
    </item>
    <item>
      <title>Trouble using variable in the FOR EACH statement rather than a literal</title>
      <link>https://community.qlik.com/t5/QlikView/Trouble-using-variable-in-the-FOR-EACH-statement-rather-than-a/m-p/173460#M502589</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;You may read that currency codes from a file or whatever, with something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;CurrencyCodes:LOAD CONCAT(CurrencyCode, chr(39) &amp;amp; ',' &amp;amp; chr(39)) AS CurrencyCodeFROM FILE.QVD (qvd);&lt;BR /&gt;LET vCurrencyCodes = chr(39) &amp;amp; Peek('CurrencyCode') &amp;amp; chr(39);&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Then use vCurrencyCodes in the For Each statement.&lt;/P&gt;&lt;P&gt;Hope that helps&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Aug 2010 08:54:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Trouble-using-variable-in-the-FOR-EACH-statement-rather-than-a/m-p/173460#M502589</guid>
      <dc:creator>Miguel_Angel_Baeyens</dc:creator>
      <dc:date>2010-08-25T08:54:41Z</dc:date>
    </item>
    <item>
      <title>Trouble using variable in the FOR EACH statement rather than a literal</title>
      <link>https://community.qlik.com/t5/QlikView/Trouble-using-variable-in-the-FOR-EACH-statement-rather-than-a/m-p/173461#M502590</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the response. We are still having the problem of the whole string of currencies being passed in at once?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ProntoCurrencyTemp:&lt;/P&gt;&lt;P&gt;LOAD DISTINCT CurrencyCode AS CurrencyCodeTemp&lt;/P&gt;&lt;P&gt;FROM DWPurchaseOrders.qvd (qvd)&lt;/P&gt;&lt;P&gt;WHERE len(CurrencyCode) = '3';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ProntoCurrency:&lt;/P&gt;&lt;P&gt;LOAD CONCAT(CurrencyCodeTemp, chr(39) &amp;amp; ',' &amp;amp; chr(39)) AS CurrencyCode&lt;/P&gt;&lt;P&gt;RESIDENT ProntoCurrencyTemp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DROP TABLE ProntoCurrencyTemp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET vBaseCurrency = 'ZAR';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET vMinDate = Date(today() - 499,'DD/MM/YY');&lt;/P&gt;&lt;P&gt;LET vMaxDate = Date(today(),'DD/MM/YY') ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET vCurrencyCodes = chr(39) &amp;amp; Peek('CurrencyCode') &amp;amp; chr(39);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FOR EACH vConvertCurrency IN vCurrencyCodes&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RawRate:&lt;/P&gt;&lt;P&gt;LOAD Replace(@1,'.','/') as Date,&lt;/P&gt;&lt;P&gt;$(vCurrencyCodes) as Currency,&lt;/P&gt;&lt;P&gt;@2 as Rate&lt;/P&gt;&lt;P&gt;FROM&lt;/P&gt;&lt;P&gt;[http://www.oanda.com/currency/historical-rates?date_fmt=normal&amp;amp;date=$(vMaxDate)&amp;amp;date1=$(vMinDate)&amp;amp;exch=$(vBaseCurrency)&amp;amp;exch2=$(vBaseCurrency)&amp;amp;expr=$(vConvertCurrency)&amp;amp;expr2=$(vConvertCurrency)&amp;amp;margin_fixed=0&amp;amp;format=HTML&amp;amp;redirected=1]&lt;/P&gt;&lt;P&gt;(html, codepage is 1252, no labels, table is @1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NEXT&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Aug 2010 02:36:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Trouble-using-variable-in-the-FOR-EACH-statement-rather-than-a/m-p/173461#M502590</guid>
      <dc:creator />
      <dc:date>2010-08-26T02:36:11Z</dc:date>
    </item>
    <item>
      <title>Trouble using variable in the FOR EACH statement rather than a literal</title>
      <link>https://community.qlik.com/t5/QlikView/Trouble-using-variable-in-the-FOR-EACH-statement-rather-than-a/m-p/173462#M502591</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I think you should change&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;$(vCurrencyCodes) as Currency,&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;for&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;$(vConvertCurrency) as Currency,&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;as vConvertCurrency is the variable that contains for each loop just one of the several elements in vCurrencyCodes.&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Aug 2010 07:14:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Trouble-using-variable-in-the-FOR-EACH-statement-rather-than-a/m-p/173462#M502591</guid>
      <dc:creator>Miguel_Angel_Baeyens</dc:creator>
      <dc:date>2010-08-26T07:14:23Z</dc:date>
    </item>
    <item>
      <title>Trouble using variable in the FOR EACH statement rather than a literal</title>
      <link>https://community.qlik.com/t5/QlikView/Trouble-using-variable-in-the-FOR-EACH-statement-rather-than-a/m-p/173463#M502592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Miguel&lt;/P&gt;&lt;P&gt;I have corrected this, but it appears that the whole string - i.e. all the currencies are being passed in as one value as shown below?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://community.qlik.com/cfs-file.ashx/__key/CommunityServer.Discussions.Components.Files/11/4265.QlikView-Currencey-error.png"&gt;&lt;IMG alt="" border="0" src="http://community.qlik.com/resized-image.ashx/__size/550x0/__key/CommunityServer.Discussions.Components.Files/11/4265.QlikView-Currencey-error.png" /&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Aug 2010 04:21:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Trouble-using-variable-in-the-FOR-EACH-statement-rather-than-a/m-p/173463#M502592</guid>
      <dc:creator />
      <dc:date>2010-08-30T04:21:26Z</dc:date>
    </item>
    <item>
      <title>Trouble using variable in the FOR EACH statement rather than a literal</title>
      <link>https://community.qlik.com/t5/QlikView/Trouble-using-variable-in-the-FOR-EACH-statement-rather-than-a/m-p/173464#M502593</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I missed the variable expansion in the for each line:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;FOR EACH vConvertCurrency IN &lt;B&gt;$(vCurrencyCodes)&lt;/B&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Hope that works.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Aug 2010 09:00:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Trouble-using-variable-in-the-FOR-EACH-statement-rather-than-a/m-p/173464#M502593</guid>
      <dc:creator>Miguel_Angel_Baeyens</dc:creator>
      <dc:date>2010-08-30T09:00:12Z</dc:date>
    </item>
    <item>
      <title>Trouble using variable in the FOR EACH statement rather than a literal</title>
      <link>https://community.qlik.com/t5/QlikView/Trouble-using-variable-in-the-FOR-EACH-statement-rather-than-a/m-p/173465#M502594</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is it! Thank you so much for your assistance &lt;IMG alt="Smile" src="http://community.qlik.com/emoticons/emotion-1.gif" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Aug 2010 09:37:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Trouble-using-variable-in-the-FOR-EACH-statement-rather-than-a/m-p/173465#M502594</guid>
      <dc:creator />
      <dc:date>2010-08-30T09:37:48Z</dc:date>
    </item>
  </channel>
</rss>

