title: YoY comparison using QlikView
body: <p>My data contains daily data from last March till now. I want to compare the sales amount of 2015/4 vs 2014/4 and 2015/4 vs 2015/3.</p>
  
  <p>My date format is 01,02,03,04,...,12 for <code>Date_Month</code>, and 2014,2015 for <code>Date_Year</code>.</p>
  
  <p>I first create two variables:</p>
  
  <pre><code>vCurrentYear=max(Date_Year)
  vCurrentMonth=Max (Date_Month)
  </code></pre>
  
  <p>Then I create a bar chart and my expressions are as below:</p>
  
  <pre><code>Last Year:
  
  Sum({&lt;[Date_Year]={$(=(vCurrentYear)-1)}Date_Month={"&lt;=$(vCurrentMonth)"}&gt;}[SALES_AMOUNT])
  
  Current Year:
  
  Sum({&lt;[Date_Year]={$(vCurrentYear)},Date_Month={"&lt;=$(vCurrentMonth)"}&gt;}SALES_AMOUNT)
  </code></pre>
  
  <p>But the result is only adding two years together.... not comparing the two years. The graph link is as below:</p>
  
  <p><a href="http://www.2shared.com/photo/xlG-XpI7/yoy.html" rel="nofollow">http://www.2shared.com/photo/xlG-XpI7/yoy.html</a></p>
  
  <p>I want a bar chart with two different bars for different years, the x axis is Date_Month.</p>
  
  <p>I am using QlikView 11.20.12664.0 SR9.</p>