<?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 behaving differently when loaded as a variable in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Expression-behaving-differently-when-loaded-as-a-variable/m-p/662984#M1082301</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I changed my input file from CSV to XLS so that I could more easily embed the double quotes in the expression values. I reloaded everything, and I am still seeing the same issue, so this does not seem to have helped.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 26 Jun 2014 17:24:51 GMT</pubDate>
    <dc:creator />
    <dc:date>2014-06-26T17:24:51Z</dc:date>
    <item>
      <title>Expression behaving differently when loaded as a variable</title>
      <link>https://community.qlik.com/t5/QlikView/Expression-behaving-differently-when-loaded-as-a-variable/m-p/662981#M1082295</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have the following expression, which I was using in a few places:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum({&amp;lt;YearMonthField={'&amp;lt;=$(=max(YearMonthField))&amp;gt;=$(=max(YearMonthField) -300)'}&amp;gt;}Plays)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I started moving some common expressions into a CSV file and importing them in script as variables, so that I could keep everything in one place.&amp;nbsp; When I did this, the above expression started giving a different result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's being imported in my file as:&lt;/P&gt;&lt;P&gt;"var4a","sum({&amp;lt;YearMonthField={'&amp;lt;=$(=max(YearMonthField))&amp;gt;=$(=max(YearMonthField) -300)'}&amp;gt;}Plays)"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To debug, I created a straight table where I put 2 columns side by side - one is the literal expression, the other is just $(var4a).&lt;/P&gt;&lt;P&gt;I attached a picture of what I'm seeing.&amp;nbsp; It's like the "=max(YearMonthField)" parts of the expression are not being evaluated when it's loaded as a variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas? Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2014 14:45:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Expression-behaving-differently-when-loaded-as-a-variable/m-p/662981#M1082295</guid>
      <dc:creator />
      <dc:date>2014-06-26T14:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: Expression behaving differently when loaded as a variable</title>
      <link>https://community.qlik.com/t5/QlikView/Expression-behaving-differently-when-loaded-as-a-variable/m-p/662982#M1082296</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;EDIT:&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;sum({&amp;lt;YearMonthField={"&amp;lt;=$(=max(YearMonthField))&amp;gt;=$(=max(YearMonthField) -300)"}&amp;gt;}Plays)&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;pls use "$(=max(YearMonthField))" inside set analysis&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2014 14:50:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Expression-behaving-differently-when-loaded-as-a-variable/m-p/662982#M1082296</guid>
      <dc:creator>sudeepkm</dc:creator>
      <dc:date>2014-06-26T14:50:21Z</dc:date>
    </item>
    <item>
      <title>Re: Expression behaving differently when loaded as a variable</title>
      <link>https://community.qlik.com/t5/QlikView/Expression-behaving-differently-when-loaded-as-a-variable/m-p/662983#M1082298</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So it's just double quote instead of single quote?&lt;/P&gt;&lt;P&gt;How would I load this in my CSV file of expressions?&amp;nbsp; I tried a \" to escape the quote in the expression, but it seems to literally load \" instead of just ".&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2014 14:57:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Expression-behaving-differently-when-loaded-as-a-variable/m-p/662983#M1082298</guid>
      <dc:creator />
      <dc:date>2014-06-26T14:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: Expression behaving differently when loaded as a variable</title>
      <link>https://community.qlik.com/t5/QlikView/Expression-behaving-differently-when-loaded-as-a-variable/m-p/662984#M1082301</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I changed my input file from CSV to XLS so that I could more easily embed the double quotes in the expression values. I reloaded everything, and I am still seeing the same issue, so this does not seem to have helped.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2014 17:24:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Expression-behaving-differently-when-loaded-as-a-variable/m-p/662984#M1082301</guid>
      <dc:creator />
      <dc:date>2014-06-26T17:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: Expression behaving differently when loaded as a variable</title>
      <link>https://community.qlik.com/t5/QlikView/Expression-behaving-differently-when-loaded-as-a-variable/m-p/662985#M1082302</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hey I'm not sure if this will resolve your issue but I had the same end result where a piece of the expression within a dollar expansion wasn't being evaluated when passed using a variable and found a solution so am just passing it on in case of use.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Background of my issue - to improve transparency and maintenance, I defined my expressions in the script with variables, which I then used in all my charts and tables etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I had my expressions defined directly in the chart/table, they worked grand, but when I moved those exact same definitions into variables some didn't work because a dollar expansion wasn't getting evaluated correctly.&lt;/P&gt;&lt;P&gt;For example I had the following set analysis expression:&lt;/P&gt;&lt;P&gt;sum({1&amp;lt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TDate={'$(vSelTDate)'}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,IsTDay={'Y'}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,Dept={'HR'}&lt;/P&gt;&lt;P&gt;&amp;gt;}[Total Qty])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I converted this to a variable as follows (note that I used double quotes around the set analysis values and the whole variable definition is between 2 single quotes):&lt;/P&gt;&lt;P&gt;LET vTotalQtySelDate =&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'sum({1&amp;lt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TDate={"$(vSelTDate)"}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,IsTDay&lt;SPAN style="font-size: 10pt;"&gt;={"Y"}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,Dept={'HR'}&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;gt;}[Total Qty])'&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However the TDate filter in this would not evaluate correctly - like your example, it came out as &lt;/P&gt;&lt;P&gt;TDate={""}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So after a search on this forum, I found a fix/workaround that has resolved this for me; when the expression of your variable contains a dollar expansion, you have to separate out the $ symbol into its own string.&lt;/P&gt;&lt;P&gt;So with the above example, the following definition works perfectly.&lt;/P&gt;&lt;P&gt;As this can be hard to read in a browser, I'll just point out that &lt;STRONG&gt;TDate={&lt;/STRONG&gt; is followed by a double quote which is the start of the value to be passed in to filter the TDate field and then a single quote to end the string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET vTotalQtySelDate =&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'sum({1&amp;lt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TDate={"' &lt;STRONG&gt;&amp;amp; '$'&lt;/STRONG&gt; &lt;STRONG&gt;&amp;amp; '(vSelTDate)"}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,IsTDay={"Y"}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,Dept={'HR'}&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;gt;}[Total Qty])'&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope it helps anyways!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Jul 2014 15:53:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Expression-behaving-differently-when-loaded-as-a-variable/m-p/662985#M1082302</guid>
      <dc:creator />
      <dc:date>2014-07-04T15:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: Expression behaving differently when loaded as a variable</title>
      <link>https://community.qlik.com/t5/QlikView/Expression-behaving-differently-when-loaded-as-a-variable/m-p/662986#M1082303</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;you can also use functions Chr(34) for double quotes or chr(39) for single quotes as escape functions,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Jul 2014 18:40:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Expression-behaving-differently-when-loaded-as-a-variable/m-p/662986#M1082303</guid>
      <dc:creator>jaimeaguilar</dc:creator>
      <dc:date>2014-07-04T18:40:50Z</dc:date>
    </item>
  </channel>
</rss>

