<?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: Error in expression with variable in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Error-in-expression-with-variable/m-p/294003#M587216</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Erich solution likley works very well, but in the long run you will be better of getting in control of and using the date/time functions that qlikview provide as these open up possibilites to do more efficient calculations with dates and timestamps. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An other possibility is that your data is not properly formatted in the table, meaning that year for example is not a integer value but has decimal value as well. This is easier to evaluate if you can provide a smaple of your QVW.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could use num(&lt;SPAN style="font-family: courier new, courier; color: #000000;"&gt;vLastMonth&lt;/SPAN&gt;) and num(&lt;SPAN style="font-family: courier new, courier; color: #000000;"&gt;vLastYear&lt;/SPAN&gt;) to see the exact numeric value of the variables. Then follow it up by adding a list boxes with Num(&lt;SPAN style="font-family: Courier New; color: #000000;"&gt;AnoEmissao&lt;/SPAN&gt;) and Num(&lt;SPAN style="font-family: Courier New; color: #000000;"&gt;MesEmissao&lt;/SPAN&gt;) so that you can confirm that the values you are trying to apply really exist. This should also reveal to you if your table have solid integer, decimal och even textual values.&lt;/P&gt;&lt;DIV class="mcePaste" id="_mcePaste" style="position: absolute; width: 1px; height: 1px; overflow: hidden; top: 0px; left: -10000px;"&gt;﻿&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 12 May 2011 13:57:22 GMT</pubDate>
    <dc:creator>ToniKautto</dc:creator>
    <dc:date>2011-05-12T13:57:22Z</dc:date>
    <item>
      <title>Error in expression with variable</title>
      <link>https://community.qlik.com/t5/QlikView/Error-in-expression-with-variable/m-p/293998#M587211</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have two variables, to get the year and month of the last date.&lt;/P&gt;&lt;P&gt;The variables are defined like this:&lt;SPAN style="color: #000000;"&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: courier new,courier;"&gt;vLastMonth= Month(Max(DataEmissao)) , and vLastYear= Year(Max(DataEmissao))&amp;nbsp; &lt;/SPAN&gt;// DataEmissao is a Date Field&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The variable are getting the right value, no problem on that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I have an expression chart, that is like this:&amp;nbsp; &lt;SPAN style="font-family: courier new,courier; color: #000000;"&gt;sum({$&amp;lt;AnoEmissao={2011}, MesEmissao={May} &amp;gt;}&amp;nbsp; TotalItem)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; color: #000000;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The expression also works, but every month I need to change it to the last month. I want to use the variable, but i dont know how. &lt;/P&gt;&lt;P&gt;I tried this: &lt;SPAN style="font-family: courier new,courier; color: #000000;"&gt;sum({$&amp;lt;AnoEmissao={$(vLastYear)}, MesEmissao={$(&lt;SPAN style="color: #000000; font-family: courier new,courier;"&gt;vLastMonth&lt;/SPAN&gt;)} &amp;gt;}&amp;nbsp; TotalItem)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I also tried a lot of variations of that, but still no sucess!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help me!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 May 2011 12:51:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Error-in-expression-with-variable/m-p/293998#M587211</guid>
      <dc:creator />
      <dc:date>2011-05-12T12:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: Error in expression with variable</title>
      <link>https://community.qlik.com/t5/QlikView/Error-in-expression-with-variable/m-p/293999#M587212</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You probabaly need to format the variables, since the variable as such is a decimal value and not a "Year" or "Month" value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LastMonth= Month(Month#(Max(DataEmissao))) &lt;/P&gt;&lt;P&gt;vLastYear= Year(Year#(Max(DataEmissao)))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When working with dates always keep in mind that you are working with Dual values, where calculation is done on the numeric value and presentation with the&amp;nbsp; textual value. This is why you often need to use for example Date(Date#()) to alter both the numeric and textual value of the variable or field. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 May 2011 12:56:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Error-in-expression-with-variable/m-p/293999#M587212</guid>
      <dc:creator>ToniKautto</dc:creator>
      <dc:date>2011-05-12T12:56:58Z</dc:date>
    </item>
    <item>
      <title>Re: Error in expression with variable</title>
      <link>https://community.qlik.com/t5/QlikView/Error-in-expression-with-variable/m-p/294000#M587213</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, it did not work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Still, I dont know the &lt;SPAN class="hps trans-target" title="Clique para mostrar traduções alternativas"&gt;exactly sintax of the expression when using variables.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="hps trans-target" title="Clique para mostrar traduções alternativas"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="hps trans-target" title="Clique para mostrar traduções alternativas"&gt;Thanks anyway.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 May 2011 13:20:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Error-in-expression-with-variable/m-p/294000#M587213</guid>
      <dc:creator />
      <dc:date>2011-05-12T13:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: Error in expression with variable</title>
      <link>https://community.qlik.com/t5/QlikView/Error-in-expression-with-variable/m-p/294001#M587214</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's better if you compare date fields on set analysis using numbers. &lt;/P&gt;&lt;P&gt;On your script I would create another field called nMesEmissao&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The sintax will be &lt;/P&gt;&lt;P&gt;num(Month(DataEmissao))) as nMesEmissao&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Similarly, &lt;/P&gt;&lt;P&gt;vLastMonth= num( Month(Max(DataEmissao)) )&lt;/P&gt;&lt;P&gt;Thus, &lt;/P&gt;&lt;P&gt;Jan =1 &lt;/P&gt;&lt;P&gt;Feb = 2 and so on... &lt;/P&gt;&lt;P&gt;This might solve your set analysis problem. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 May 2011 13:25:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Error-in-expression-with-variable/m-p/294001#M587214</guid>
      <dc:creator>erichshiino</dc:creator>
      <dc:date>2011-05-12T13:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: Error in expression with variable</title>
      <link>https://community.qlik.com/t5/QlikView/Error-in-expression-with-variable/m-p/294002#M587215</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Erich and Toni,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but after try a lot of expressions, I finally found the right way.&lt;/P&gt;&lt;P&gt;I forgot to use ". &lt;/P&gt;&lt;P&gt;So, the right expression is &lt;SPAN style="font-family: courier new,courier; color: #000000;"&gt;sum({$&amp;lt;AnoEmissao={"$(vUltAno)"}, MesEmissao={"$(vUltmes)"} &amp;gt;}&amp;nbsp; TotalItem)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; color: #333333; font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; color: #333333; font-size: 10pt;"&gt;Thanks all&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; color: #333333; font-size: 10pt;"&gt;﻿&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; color: #333333; font-size: 10pt;"&gt;﻿Rogério Faria&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 May 2011 13:51:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Error-in-expression-with-variable/m-p/294002#M587215</guid>
      <dc:creator />
      <dc:date>2011-05-12T13:51:52Z</dc:date>
    </item>
    <item>
      <title>Re: Error in expression with variable</title>
      <link>https://community.qlik.com/t5/QlikView/Error-in-expression-with-variable/m-p/294003#M587216</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Erich solution likley works very well, but in the long run you will be better of getting in control of and using the date/time functions that qlikview provide as these open up possibilites to do more efficient calculations with dates and timestamps. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An other possibility is that your data is not properly formatted in the table, meaning that year for example is not a integer value but has decimal value as well. This is easier to evaluate if you can provide a smaple of your QVW.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could use num(&lt;SPAN style="font-family: courier new, courier; color: #000000;"&gt;vLastMonth&lt;/SPAN&gt;) and num(&lt;SPAN style="font-family: courier new, courier; color: #000000;"&gt;vLastYear&lt;/SPAN&gt;) to see the exact numeric value of the variables. Then follow it up by adding a list boxes with Num(&lt;SPAN style="font-family: Courier New; color: #000000;"&gt;AnoEmissao&lt;/SPAN&gt;) and Num(&lt;SPAN style="font-family: Courier New; color: #000000;"&gt;MesEmissao&lt;/SPAN&gt;) so that you can confirm that the values you are trying to apply really exist. This should also reveal to you if your table have solid integer, decimal och even textual values.&lt;/P&gt;&lt;DIV class="mcePaste" id="_mcePaste" style="position: absolute; width: 1px; height: 1px; overflow: hidden; top: 0px; left: -10000px;"&gt;﻿&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 May 2011 13:57:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Error-in-expression-with-variable/m-p/294003#M587216</guid>
      <dc:creator>ToniKautto</dc:creator>
      <dc:date>2011-05-12T13:57:22Z</dc:date>
    </item>
  </channel>
</rss>

