<?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: Variables which reference other variables in the script in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Variables-which-reference-other-variables-in-the-script/m-p/1850415#M1215605</link>
    <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/16043"&gt;@sam_grounds&lt;/a&gt;&amp;nbsp; - four years later, you've saved me from tearing all of my hair out or banging my head on my desk one too many times - many, many thanks!&lt;/P&gt;</description>
    <pubDate>Fri, 22 Oct 2021 01:48:16 GMT</pubDate>
    <dc:creator>millerhm</dc:creator>
    <dc:date>2021-10-22T01:48:16Z</dc:date>
    <item>
      <title>Variables which reference other variables in the script</title>
      <link>https://community.qlik.com/t5/QlikView/Variables-which-reference-other-variables-in-the-script/m-p/1418833#M428313</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif;"&gt;Hi all,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif;"&gt;I've had a pesky issue in the past with the dollar expansion. A great feature, but can cause problems if you don't know how to avoid it... &lt;SPAN style="font-size: 10pt;"&gt;I often want to write a large number of variables, which I paste into my script, sometimes using a program like excel to use a formulaic pattern to writing them.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif;"&gt;An example would be this...&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-size: 13.3333px; font-family: calibri, verdana, arial, sans-serif;"&gt;Variable name: vSales&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-size: 13.3333px; font-family: calibri, verdana, arial, sans-serif;"&gt;Desired value: num(sum({$&amp;lt;[Transaction Date]='$(vDate)'}&amp;gt;}Sales),'£#,##0')&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif;"&gt;There a couple of problems with this approach, the first of all is the use of single quotes. If you want to write a single quote into a variable using the script, use the chr(39) function instead.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif;"&gt;Simply replace all single quotes with this&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif;"&gt;'&amp;amp;chr(39)&amp;amp;'&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif;"&gt;(including the single quotes)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif;"&gt;Secondly, the dollar expansion will evaluate the variable there and then and write it in, in place of the variable name, rather than allowing it to reference the variable directly.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif;"&gt;In order to stop the dollar expansion evaluating the string contained in the variable, simply break the dollar and opening bracket up. &lt;SPAN style="font-size: 10pt;"&gt;Like so...&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif;"&gt;$'&amp;amp;'(&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif;"&gt;Simple, yet effective. &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif;"&gt;So the best way I have found to write this into the script would be...&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif;"&gt;LET vSales_Yesterday='num(sum({$&amp;lt;[Transaction Date]={'&amp;amp;chr(39)&amp;amp;'$'&amp;amp;'(vDate)'&amp;amp;chr(39)&amp;amp;'}&amp;gt;}Sales),'&amp;amp;chr(39)&amp;amp;'£#,##0'&amp;amp;chr(39)&amp;amp;')';&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif;"&gt;This will create a variable...&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif;"&gt;vSales&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif;"&gt;which contains...&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif;"&gt;num(sum({$&amp;lt;[Transaction Date]={'$(vDate)'}&amp;gt;}Sales),'£#,##0')&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif;"&gt;This approach basically tweaks what is being evaluated the first time (by the script) to produce a string which later on when it is evaluated it can repeatedly use the other variable in the front end expressions.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif;"&gt;Hope this helps someone else who encounters the same issue.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif;"&gt;Sam &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Sep 2017 14:47:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variables-which-reference-other-variables-in-the-script/m-p/1418833#M428313</guid>
      <dc:creator>sam_grounds</dc:creator>
      <dc:date>2017-09-14T14:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: Variables which reference other variables in the script</title>
      <link>https://community.qlik.com/t5/QlikView/Variables-which-reference-other-variables-in-the-script/m-p/1850415#M1215605</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/16043"&gt;@sam_grounds&lt;/a&gt;&amp;nbsp; - four years later, you've saved me from tearing all of my hair out or banging my head on my desk one too many times - many, many thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 01:48:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variables-which-reference-other-variables-in-the-script/m-p/1850415#M1215605</guid>
      <dc:creator>millerhm</dc:creator>
      <dc:date>2021-10-22T01:48:16Z</dc:date>
    </item>
    <item>
      <title>Re: Variables which reference other variables in the script</title>
      <link>https://community.qlik.com/t5/QlikView/Variables-which-reference-other-variables-in-the-script/m-p/1994158#M1221296</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/16043"&gt;@sam_grounds&lt;/a&gt;&amp;nbsp; Same here.&amp;nbsp; &amp;nbsp;Nice tip.&amp;nbsp; &amp;nbsp;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2022 20:07:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variables-which-reference-other-variables-in-the-script/m-p/1994158#M1221296</guid>
      <dc:creator>jda_bryan</dc:creator>
      <dc:date>2022-10-18T20:07:50Z</dc:date>
    </item>
  </channel>
</rss>

