<?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: Variable in Expression stored as Variable in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Variable-in-Expression-stored-as-Variable/m-p/1360879#M616432</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The $ expansion in the set statement IS evaluated (even though this a SET):&lt;/P&gt;&lt;P&gt;&lt;EM&gt;SET vExp_Amount = sum({$&amp;lt;Age={'&lt;STRONG&gt;$(vAgeRange)&lt;/STRONG&gt;'}&amp;gt;} Amount);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As $(vAgeRange) may expand to &amp;lt;empty string&amp;gt; at this stage in the script execution, so the actual statement will become:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;SET vExp_Amount = sum({$&amp;lt;Age={''}&amp;gt;} Amount);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which is not what you want. To get around this, defer the evaluation like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Set vExp_Amount = sum({$&amp;lt;Age={'#(vAgeRange)'}&amp;gt;} Amount);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Let vExp_Amount = Replace(vExp_Amount, '#', '$');&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does that answer your question?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 04 May 2017 08:50:32 GMT</pubDate>
    <dc:creator>jonathandienst</dc:creator>
    <dc:date>2017-05-04T08:50:32Z</dc:date>
    <item>
      <title>Variable in Expression stored as Variable</title>
      <link>https://community.qlik.com/t5/QlikView/Variable-in-Expression-stored-as-Variable/m-p/1360877#M616430</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;!Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Currently I have this expression:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum({$&amp;lt;Age={'$(vAgeRange)'}&amp;gt;} Amount)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have 2 buttons in my layout with an action that will change the value of the vAgeRange variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, I need to store this expression in a variable in the script so that I can call the variable in my chart instead of using the expression in chart.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SET vExp_Amount = sum({$&amp;lt;Age={'$(vAgeRange)'}&amp;gt;} Amount);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is that the vAgeRange will be evaluated in the script level. Due to this, the expression become static in the chart (since the vAgeRange is not evaluated anymore in the chart)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any idea on how I can get around this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Attached is the example with the 2 workarounds suggested below. Thanks for the help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 May 2017 01:56:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variable-in-Expression-stored-as-Variable/m-p/1360877#M616430</guid>
      <dc:creator>KHSDM</dc:creator>
      <dc:date>2017-05-04T01:56:05Z</dc:date>
    </item>
    <item>
      <title>Re: Variable in Expression stored as Variable</title>
      <link>https://community.qlik.com/t5/QlikView/Variable-in-Expression-stored-as-Variable/m-p/1360878#M616431</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try in text object like &lt;STRONG&gt;$(&lt;/STRONG&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;STRONG&gt;vAgeRange)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 May 2017 08:35:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variable-in-Expression-stored-as-Variable/m-p/1360878#M616431</guid>
      <dc:creator>Anil_Babu_Samineni</dc:creator>
      <dc:date>2017-05-04T08:35:32Z</dc:date>
    </item>
    <item>
      <title>Re: Variable in Expression stored as Variable</title>
      <link>https://community.qlik.com/t5/QlikView/Variable-in-Expression-stored-as-Variable/m-p/1360879#M616432</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The $ expansion in the set statement IS evaluated (even though this a SET):&lt;/P&gt;&lt;P&gt;&lt;EM&gt;SET vExp_Amount = sum({$&amp;lt;Age={'&lt;STRONG&gt;$(vAgeRange)&lt;/STRONG&gt;'}&amp;gt;} Amount);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As $(vAgeRange) may expand to &amp;lt;empty string&amp;gt; at this stage in the script execution, so the actual statement will become:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;SET vExp_Amount = sum({$&amp;lt;Age={''}&amp;gt;} Amount);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which is not what you want. To get around this, defer the evaluation like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Set vExp_Amount = sum({$&amp;lt;Age={'#(vAgeRange)'}&amp;gt;} Amount);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Let vExp_Amount = Replace(vExp_Amount, '#', '$');&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does that answer your question?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 May 2017 08:50:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variable-in-Expression-stored-as-Variable/m-p/1360879#M616432</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2017-05-04T08:50:32Z</dc:date>
    </item>
    <item>
      <title>Re: Variable in Expression stored as Variable</title>
      <link>https://community.qlik.com/t5/QlikView/Variable-in-Expression-stored-as-Variable/m-p/1360880#M616433</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is another option suggested by Stefan here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/thread/220964"&gt;Expression as a variable with $-sign expansion&lt;/A&gt;‌&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;STRONG&gt;LET vExp_Amount = &lt;SPAN style="color: #ff0000;"&gt;'&lt;/SPAN&gt;Sum({$&amp;lt;Age={&lt;SPAN style="color: #0000ff;"&gt;"&lt;/SPAN&gt;$&lt;SPAN style="color: #ff0000;"&gt;' &amp;amp; '&lt;/SPAN&gt;(vAgeRange)&lt;STRONG style="color: #0000ff; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;"&lt;/STRONG&gt;}&amp;gt;} Amount)&lt;SPAN style="color: #ff0000;"&gt;'&lt;/SPAN&gt;;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 May 2017 11:20:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variable-in-Expression-stored-as-Variable/m-p/1360880#M616433</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2017-05-04T11:20:40Z</dc:date>
    </item>
    <item>
      <title>Re: Variable in Expression stored as Variable</title>
      <link>https://community.qlik.com/t5/QlikView/Variable-in-Expression-stored-as-Variable/m-p/1360881#M616434</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Jonathan and Sunny! Both methods works, but I've chosen Jonathan's method as it is easier to read. I've edited my first post with an example containing both method. Hope this will help others. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 May 2017 01:22:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variable-in-Expression-stored-as-Variable/m-p/1360881#M616434</guid>
      <dc:creator>KHSDM</dc:creator>
      <dc:date>2017-05-05T01:22:45Z</dc:date>
    </item>
  </channel>
</rss>

