<?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: Help with script variable usage in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Help-with-script-variable-usage/m-p/953550#M327866</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dude, you rock!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 28 Sep 2015 19:07:05 GMT</pubDate>
    <dc:creator>tschullo</dc:creator>
    <dc:date>2015-09-28T19:07:05Z</dc:date>
    <item>
      <title>Help with script variable usage</title>
      <link>https://community.qlik.com/t5/QlikView/Help-with-script-variable-usage/m-p/953546#M327862</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;&amp;nbsp; &lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;FOR&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;EACH&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style="color: #808080; font-size: 8pt;"&gt;&lt;STRONG&gt;&lt;EM style="color: #808080; font-size: 8pt;"&gt;wNums&lt;/EM&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;in&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; '76','1226,1250','1251,1255','1256,1268','1269,1273','1274,1280','1281,1290','1291,1300','1301,1311','1312,1321','1322,1335','1336,1345'&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style="color: #808080; font-size: 8pt;"&gt;&lt;STRONG&gt;&lt;EM style="color: #808080; font-size: 8pt;"&gt;myFlag&lt;/EM&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 8pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;index&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;chr&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(39) &amp;amp; &lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style="color: #808080; font-size: 8pt;"&gt;&lt;STRONG&gt;&lt;EM style="color: #808080; font-size: 8pt;"&gt;$(wNums)&lt;/EM&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 8pt;"&gt; &amp;amp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;chr&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(39),',');&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;if&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style="color: #808080; font-size: 8pt;"&gt;&lt;STRONG&gt;&lt;EM style="color: #808080; font-size: 8pt;"&gt;$(myFlag)&lt;/EM&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 8pt;"&gt; &amp;gt; 0 &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;Then&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;LET&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style="color: #808080; font-size: 8pt;"&gt;&lt;STRONG&gt;&lt;EM style="color: #808080; font-size: 8pt;"&gt;wClause&lt;/EM&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 8pt;"&gt; = 'BETWEEN ' &amp;amp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;subfield&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;chr&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(39) &amp;amp; &lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style="color: #808080; font-size: 8pt;"&gt;&lt;STRONG&gt;&lt;EM style="color: #808080; font-size: 8pt;"&gt;$(wNums)&lt;/EM&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 8pt;"&gt; &amp;amp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;chr&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(39),',',1) &amp;amp; ' AND ' &amp;amp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;subfield&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;chr&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(39) &amp;amp; &lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style="color: #808080; font-size: 8pt;"&gt;&lt;STRONG&gt;&lt;EM style="color: #808080; font-size: 8pt;"&gt;$(wNums)&lt;/EM&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 8pt;"&gt; &amp;amp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;chr&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(39),',',2);&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;else&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;LET&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style="color: #808080; font-size: 8pt;"&gt;&lt;STRONG&gt;&lt;EM style="color: #808080; font-size: 8pt;"&gt;wClause&lt;/EM&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 8pt;"&gt; = '=' &amp;amp; &lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style="color: #808080; font-size: 8pt;"&gt;&lt;STRONG&gt;&lt;EM style="color: #808080; font-size: 8pt;"&gt;$(wNums)&lt;/EM&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 8pt;"&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;end&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000; font-size: 8pt;"&gt;//wClause = if(index($(wNums),','),'BETWEEN ' &amp;amp; subfield( $(wNums) ,',',1) &amp;amp; ' AND ' &amp;amp; subfield( $(wNums) ,',',2),'=' &amp;amp; $(wNums));&lt;BR /&gt;//wClause = if(index(chr(39) &amp;amp; $(wNums) &amp;amp; chr(39),','),'BETWEEN ' &amp;amp; subfield(chr(39) &amp;amp; $(wNums) &amp;amp; chr(39),',',1) &amp;amp; ' AND ' &amp;amp; subfield(chr(39) &amp;amp; $(wNums) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;next wNums;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;I thought this would be simple and straightforward.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;I just want to dynamically produce a series of WHERE clauses based on parameters passed in on a FOR EACH loop.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;It's annoying that the single quotes are stripped, is their a way to not lose them?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;As you can tell by commented out code I have tried this several ways now. Any suggestions would be greatly appreciated,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;including reading material to explain the ins and outs of using variables in a script.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Also, in a FOR EACH command, is it possible to break the parameters out into more than one line?FOR&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;EACH&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style="color: #808080; font-size: 8pt;"&gt;&lt;STRONG&gt;&lt;EM style="color: #808080; font-size: 8pt;"&gt;wNums&lt;/EM&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;in&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; '76','1226,1250','1251,1255','1256,1268','1269,1273',&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '1274,1280','1281,1290','1291,1300','1301,1311','1312,1321','1322,1335','1336,1345'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-size: 8pt;"&gt;Script editor not happy when I do that.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-size: 8pt;"&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-size: 8pt;"&gt;Tony&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Sep 2015 18:30:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-with-script-variable-usage/m-p/953546#M327862</guid>
      <dc:creator>tschullo</dc:creator>
      <dc:date>2015-09-28T18:30:24Z</dc:date>
    </item>
    <item>
      <title>Re: Help with script variable usage</title>
      <link>https://community.qlik.com/t5/QlikView/Help-with-script-variable-usage/m-p/953547#M327863</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;try to use something like that:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let strWithoutQuote= ' where company in (#C1#,#C2#)';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let strWithSingleQuote = replace(strSQL,'#',Chr(39));&lt;/P&gt;&lt;P&gt;and the result will be:&lt;/P&gt;&lt;P&gt;strWhereCluase= where company in ('C1','C2')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Patric&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Sep 2015 18:42:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-with-script-variable-usage/m-p/953547#M327863</guid>
      <dc:creator>pamaxeed</dc:creator>
      <dc:date>2015-09-28T18:42:24Z</dc:date>
    </item>
    <item>
      <title>Re: Help with script variable usage</title>
      <link>https://community.qlik.com/t5/QlikView/Help-with-script-variable-usage/m-p/953548#M327864</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;EM&gt;FOR EACH wNums in '76','1226,1250','1251,1255','1256,1268','1269,1273','1274,1280','1281,1290','1291,1300','1301,1311','1312,1321','1322,1335','1336,1345'&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; //myFlag=index(chr(39) &amp;amp; $(wNums) &amp;amp; chr(39),',');&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; let myFlag=index('$(wNums)', ',');&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; //trace vNums=$(wNums)&amp;nbsp;&amp;nbsp; myFlag=$(myFlag);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; if $(myFlag) &amp;gt; 0 Then&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; //LET wClause = 'BETWEEN ' &amp;amp; subfield(chr(39) &amp;amp; $(wNums) &amp;amp; chr(39),',',1) &amp;amp; ' AND ' &amp;amp; subfield(chr(39) &amp;amp; $(wNums) &amp;amp; chr(39),',',2);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; LET wClause = 'BETWEEN ' &amp;amp; subfield('$(wNums)',',',1) &amp;amp; ' AND ' &amp;amp; subfield('$(wNums)',',',2);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; else&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; //LET wClause = '=' &amp;amp; $(wNums);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; LET wClause = '=$(wNums)';&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; end if;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; //wClause = if(index($(wNums),','),'BETWEEN ' &amp;amp; subfield( $(wNums) ,',',1) &amp;amp; ' AND ' &amp;amp; subfield( $(wNums) ,',',2),'=' &amp;amp; $(wNums));&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; //wClause = if(index(chr(39) &amp;amp; $(wNums) &amp;amp; chr(39),','),'BETWEEN ' &amp;amp; subfield(chr(39) &amp;amp; $(wNums) &amp;amp; chr(39),',',1) &amp;amp; ' AND ' &amp;amp; subfield(chr(39) &amp;amp; $(wNums)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; TRACE wClause&amp;nbsp;&amp;nbsp; $(wClause);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;next wNums;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="-2.png" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/100249_-2.png" style="height: auto; width: auto;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Sep 2015 18:56:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-with-script-variable-usage/m-p/953548#M327864</guid>
      <dc:creator>maxgro</dc:creator>
      <dc:date>2015-09-28T18:56:26Z</dc:date>
    </item>
    <item>
      <title>Re: Help with script variable usage</title>
      <link>https://community.qlik.com/t5/QlikView/Help-with-script-variable-usage/m-p/953549#M327865</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In your example something like that:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FOR EACH wNums in '#1226,1250#' //,'#1251,1255#','#1256,1268#','#1269,1273#','#1274,1280#','#1281,1290#','#1291,1300#','#1301,1311#','#1312,1321#','#1322,1335#','#1336,1345#'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET wClause = '=' &amp;amp; replace(wNums,'#',Chr(39));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;next wNums;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note to get the string value of each for entry do not use $(wNums) but just wNums.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Patric&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Sep 2015 18:58:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-with-script-variable-usage/m-p/953549#M327865</guid>
      <dc:creator>pamaxeed</dc:creator>
      <dc:date>2015-09-28T18:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: Help with script variable usage</title>
      <link>https://community.qlik.com/t5/QlikView/Help-with-script-variable-usage/m-p/953550#M327866</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dude, you rock!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Sep 2015 19:07:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-with-script-variable-usage/m-p/953550#M327866</guid>
      <dc:creator>tschullo</dc:creator>
      <dc:date>2015-09-28T19:07:05Z</dc:date>
    </item>
  </channel>
</rss>

