<?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: Expression as variable not working in Set Analysis in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Expression-as-variable-not-working-in-Set-Analysis/m-p/252270#M496724</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;Try just putting sum($&amp;lt;MonthYearNum={"&amp;gt;=$(vBack6MonthYearNum)"}&amp;gt;} [Total Pounds])&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;Normally, I put the whole or part of the set analysis as a variable like&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;set vBack6MonthYear = '{$ &amp;lt;MonthYearNum = {"&amp;gt;=$(=num(MonthStart(AddMonths(max(EndMonth), -5))))"}&amp;gt;}'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;then the formula is &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;sum( $(vBack6MonthYear) [Total Pounds])&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Karl&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 05 Jan 2012 01:08:36 GMT</pubDate>
    <dc:creator>pover</dc:creator>
    <dc:date>2012-01-05T01:08:36Z</dc:date>
    <item>
      <title>Expression as variable not working in Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Expression-as-variable-not-working-in-Set-Analysis/m-p/252268#M496722</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;I am trying to integrate some variable in a set analysis, but I have difficulty to make it right.&amp;nbsp; I just wonder if anyone knows how to resolve it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(The QlikView application was built with a lot of variables, so I have to inherit the same coding standard.) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The set analysis should be evaluated like the following at the end.&amp;nbsp; This expression works when I put it under the Expression tab on a bar chart.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;sum({$ &amp;lt;MonthYearNum = {"&amp;gt;=$(=num(MonthStart(AddMonths(max(EndMonth), -5))))"}&amp;gt;} [Total Pounds])&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried the following but none of them worked:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SET vBack6MonthYearNum = '=num(MonthStart(AddMonths(max(EndMonth), -5)))';&amp;nbsp; &lt;/STRONG&gt;(this variable will be re-used in many other set analysis)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;SET vTotalPounds6MonBk1 = 'sum({$ &amp;lt;MonthYearNum = {"&amp;gt;=$($(vBack6MonthYearNum))"}&amp;gt;} [Total Pounds])'; &lt;/P&gt;&lt;P&gt;---&amp;gt; In Variable Overview it becomes &lt;SPAN style="color: #000080;"&gt;sum({$ &amp;lt;MonthYearNum = {"&amp;gt;=(internal error)"}&amp;gt;} [Total Pounds])&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SET vTotalPounds6MonBk2 = 'sum({$ &amp;lt;MonthYearNum = {"&amp;gt;=$(=$(vBack6MonthYearNum))"}&amp;gt;} [Total Pounds])'; &lt;/P&gt;&lt;P&gt;--&amp;gt; In Variable Overview it becomes &lt;SPAN style="color: #000080;"&gt;sum({$ &amp;lt;MonthYearNum = {"&amp;gt;=(internal error)"}&amp;gt;} [Total Pounds])&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;SET vTotalPounds6MonBk3 = 'sum({$ &amp;lt;MonthYearNum = {"&amp;gt;=$(=num(MonthStart(AddMonths(max(EndMonth), -5))))"}&amp;gt;} [Total Pounds])'; &lt;/P&gt;&lt;P&gt;--&amp;gt; In Variable Overview it becomes &lt;SPAN style="color: #000080;"&gt;sum({$ &amp;lt;MonthYearNum = {"&amp;gt;=(internal error)"}&amp;gt;} [Total Pounds])&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I appreciate all feedback.&amp;nbsp; Thanks a lot.&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #0000ff; font-size: 8pt;"&gt;&lt;STRONG style=": ; color: #0000ff; font-size: 8pt;"&gt; &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; &lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jan 2012 21:16:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Expression-as-variable-not-working-in-Set-Analysis/m-p/252268#M496722</guid>
      <dc:creator />
      <dc:date>2012-01-04T21:16:51Z</dc:date>
    </item>
    <item>
      <title>Re: Expression as variable not working in Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Expression-as-variable-not-working-in-Set-Analysis/m-p/252269#M496723</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try something along these lines:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set vBack6MonthYearNum = '=num(MonthStart(AddMonths(max(EndMonth), -5)))';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let vTotalPounds6MonBk1 = '=sum({$&amp;lt;MonthYearNum = {"&amp;gt;='&amp;amp;chr(36)&amp;amp; '(vBack6MonthYearNum)"}&amp;gt;} [Total Pounds])';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I need to take care that the dollar sign expansion is not done in the script, therefore I used chr(36) and Let to combine a text snippet with dollar symbol and then another text snippet. No dollar sign expansion takes place, since no dollar sign is read before the complete expression is evaluated by LET statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;edit:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternatively, you could replace the last line with these two lines, making the actual variabe definition a bit more readible:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set vTotalPounds6MonBk1 = '=sum({$&amp;lt;MonthYearNum = {"&amp;gt;=@(vBack6MonthYearNum)"}&amp;gt;} [Total Pounds])';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let vTotalPounds6MonBk1 = Replace(vTotalPounds6MonBk1,'@','$');&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jan 2012 00:55:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Expression-as-variable-not-working-in-Set-Analysis/m-p/252269#M496723</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-01-05T00:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: Expression as variable not working in Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Expression-as-variable-not-working-in-Set-Analysis/m-p/252270#M496724</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;Try just putting sum($&amp;lt;MonthYearNum={"&amp;gt;=$(vBack6MonthYearNum)"}&amp;gt;} [Total Pounds])&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;Normally, I put the whole or part of the set analysis as a variable like&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;set vBack6MonthYear = '{$ &amp;lt;MonthYearNum = {"&amp;gt;=$(=num(MonthStart(AddMonths(max(EndMonth), -5))))"}&amp;gt;}'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;then the formula is &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;sum( $(vBack6MonthYear) [Total Pounds])&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Karl&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jan 2012 01:08:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Expression-as-variable-not-working-in-Set-Analysis/m-p/252270#M496724</guid>
      <dc:creator>pover</dc:creator>
      <dc:date>2012-01-05T01:08:36Z</dc:date>
    </item>
    <item>
      <title>Re: Expression as variable not working in Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Expression-as-variable-not-working-in-Set-Analysis/m-p/252271#M496725</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Stefan is right.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only thing that I would add is that if you're going to organize numerous expressions as variables, I think a better way of doing it would be to define the variables in an Excel file and import the variables into QV using something like the example that Rocco posted&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.qlik.com/thread/27883"&gt;http://community.qlik.com/thread/27883&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Karl&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jan 2012 02:52:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Expression-as-variable-not-working-in-Set-Analysis/m-p/252271#M496725</guid>
      <dc:creator>pover</dc:creator>
      <dc:date>2012-01-05T02:52:02Z</dc:date>
    </item>
    <item>
      <title>Re: Expression as variable not working in Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Expression-as-variable-not-working-in-Set-Analysis/m-p/252272#M496726</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A _jive_internal="true" class="jiveTT-hover-user jive-username-link" href="https://community.qlik.com/people/mantingliu" id="jive-4716814169606454333203" onmouseout="" onmouseover="" style="font-size: 12px; color: #007fc0; font-weight: bold;"&gt;mantingliu&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Try adding this variable values in variable overview itself if your going to use this in charts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vBack6MonthYearNum = num(MonthStart(&lt;/STRONG&gt;&lt;STRONG style="font-size: 12px;"&gt;AddMonths&lt;/STRONG&gt;&lt;STRONG style="font-size: 12px;"&gt; &lt;/STRONG&gt;&lt;STRONG style="font-size: 12px;"&gt;(max(EndMonth), -5)));&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; vTotalPounds6MonBk1 = sum({$ &amp;lt;MonthYearNum = {"&amp;gt;=$(=$(vBack6MonthYearNum))"}&amp;gt;} [Total Pounds]);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Celambarasan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jan 2012 04:40:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Expression-as-variable-not-working-in-Set-Analysis/m-p/252272#M496726</guid>
      <dc:creator>CELAMBARASAN</dc:creator>
      <dc:date>2012-01-05T04:40:43Z</dc:date>
    </item>
    <item>
      <title>Expression as variable not working in Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Expression-as-variable-not-working-in-Set-Analysis/m-p/252273#M496727</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Stefan, your solution works perfectly!&amp;nbsp; The set analysis also uses the IF statement, so I need to reuse vBack6MonthYearNum multiple times.&amp;nbsp; Therefore, I also use your second suggestion (i.e. to do a replace.)&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot everyone!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jan 2012 20:25:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Expression-as-variable-not-working-in-Set-Analysis/m-p/252273#M496727</guid>
      <dc:creator />
      <dc:date>2012-01-05T20:25:01Z</dc:date>
    </item>
    <item>
      <title>Expression as variable not working in Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Expression-as-variable-not-working-in-Set-Analysis/m-p/252274#M496728</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Stefan, your solution works perfectly!&amp;nbsp; The set analysis also uses the IF statement, so I need to reuse vBack6MonthYearNum multiple times.&amp;nbsp; Therefore, I also use your second suggestion (i.e. to do a replace.)&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot everyone!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jan 2012 20:26:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Expression-as-variable-not-working-in-Set-Analysis/m-p/252274#M496728</guid>
      <dc:creator />
      <dc:date>2012-01-05T20:26:27Z</dc:date>
    </item>
  </channel>
</rss>

