title: Qlik - How to use Set Analysis to sum until the last available record with data instead of the last calendar date
body: <p><strong>My expression looks currently like this:</strong></p>
  
  <pre><code>Sum({$&lt;[Calendar Date] = {
  &lt;=$(=Date(MonthEnd(Date(Today()))))
  &gt;=$(=Date(AddMonths(MonthStart(Date(Today())), - 12)))"}&gt;} [Amount])
  </code></pre>
  
  <p><strong>This is how the data looks like:</strong></p>
  
  <pre><code>Companies   MonthYear   Amount
  Company1    201701  10000
  Company1    201612  20000
  Company2    201701  -
  Company2    201612  -
  Company2    201611  35000
  Company2    201610  17000
  Company3    201701  -
  Company3    201612  50000
  Company3    201611  10000
  Company3    201610  24000
  Company3    201609  40000
  Company3    201608  -
  Company3    201607  -
  Company3    201606  32000
  Company3    201605  18000
  </code></pre>
  
  <p><strong>This is what I want to achieve:</strong></p>
  
  <p>Example:</p>
  
  <ul>
  <li>Company1 has data until 201701 --> sum data from 201601 until 201701</li>
  <li>Company2 has data until 201611 --> sum data from 201511 until 201611</li>
  <li>Company3 has data until 201612 --> sum data from 201512 until 201612</li>
  </ul>
  
  <p><strong>But because I am using Today() as my limit I am having the following displayed: (THIS IS NOT WHAT I WANT TO ACHIEVE)</strong></p>
  
  <p>Example:</p>
  
  <ul>
  <li>Company1 has data until 201701 --> sum data from 201601 until 201701</li>
  <li>Company2 has data until 201611 --> sum data from 201601 until 201701</li>
  <li>Company3 has data until 201612 --> sum data from 201601 until 201701</li>
  </ul>
  
  <p>How do I need to change the expression so that my dashboard will sum the [Amount] field from the last available month with data for every company until the 12 months before that date?</p>
  
  <p><strong>PS:</strong> Today() = 23 Jan 2016</p>