<?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 Sum of Different Date Ranges in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Sum-of-Different-Date-Ranges/m-p/443313#M485405</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Qlikview Community:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to do a sum of sales for a number of different stores. Each store has a different date range that I would like to sum. When drilled down to a single store, the date range/sum is correct; however, when I am viewing all of the stores at once, the expression is using the max date (01/22/2013) for all of the stores--leading to incorrect totals for both the stores and the overall sum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stores/Date Ranges:&lt;/P&gt;&lt;P&gt;0111&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 02/04/2012 - 01/22/2013&lt;/P&gt;&lt;P&gt;0222&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 02/04/2012 - 01/21/2013&lt;/P&gt;&lt;P&gt;0333&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 02/04/2012 - 01/17/2013&lt;/P&gt;&lt;P&gt;0444&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 02/04/2012 - 01/15/2013&lt;/P&gt;&lt;P&gt;0555&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 02/04/2012 - 01/10/2013&lt;/P&gt;&lt;P&gt;0666&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 02/04/2012 - 01/09/2013&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Expression:&lt;/P&gt;&lt;P&gt;Sum({$&amp;lt;POSDate={"&amp;gt;=$(=$(vMinSIRDate))&amp;lt;=$(=Date($(vSIRRunDate)))"}&amp;gt;}SalesDol)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;POSDate = date range field&lt;/P&gt;&lt;P&gt;vMinSIRDate = 02/04/2012 (no issues with this variable)&lt;/P&gt;&lt;P&gt;vSIRRunDate = Max(RunDate)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My thinking was that this could be solved with a simple aggregation: Aggr(Sum(SalesDol),StoreNo)&lt;/P&gt;&lt;P&gt;but this does not work either--it uses 01/22/2013 for all of the stores as well. I also tried Aggregation on the Max(RunDate) and a number of different combinations of these two, but I can't get it to work correctly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any advice would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sincerely,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ben D.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 09 May 2013 12:45:44 GMT</pubDate>
    <dc:creator />
    <dc:date>2013-05-09T12:45:44Z</dc:date>
    <item>
      <title>Sum of Different Date Ranges</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-of-Different-Date-Ranges/m-p/443313#M485405</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Qlikview Community:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to do a sum of sales for a number of different stores. Each store has a different date range that I would like to sum. When drilled down to a single store, the date range/sum is correct; however, when I am viewing all of the stores at once, the expression is using the max date (01/22/2013) for all of the stores--leading to incorrect totals for both the stores and the overall sum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stores/Date Ranges:&lt;/P&gt;&lt;P&gt;0111&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 02/04/2012 - 01/22/2013&lt;/P&gt;&lt;P&gt;0222&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 02/04/2012 - 01/21/2013&lt;/P&gt;&lt;P&gt;0333&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 02/04/2012 - 01/17/2013&lt;/P&gt;&lt;P&gt;0444&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 02/04/2012 - 01/15/2013&lt;/P&gt;&lt;P&gt;0555&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 02/04/2012 - 01/10/2013&lt;/P&gt;&lt;P&gt;0666&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 02/04/2012 - 01/09/2013&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Expression:&lt;/P&gt;&lt;P&gt;Sum({$&amp;lt;POSDate={"&amp;gt;=$(=$(vMinSIRDate))&amp;lt;=$(=Date($(vSIRRunDate)))"}&amp;gt;}SalesDol)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;POSDate = date range field&lt;/P&gt;&lt;P&gt;vMinSIRDate = 02/04/2012 (no issues with this variable)&lt;/P&gt;&lt;P&gt;vSIRRunDate = Max(RunDate)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My thinking was that this could be solved with a simple aggregation: Aggr(Sum(SalesDol),StoreNo)&lt;/P&gt;&lt;P&gt;but this does not work either--it uses 01/22/2013 for all of the stores as well. I also tried Aggregation on the Max(RunDate) and a number of different combinations of these two, but I can't get it to work correctly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any advice would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sincerely,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ben D.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 May 2013 12:45:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-of-Different-Date-Ranges/m-p/443313#M485405</guid>
      <dc:creator />
      <dc:date>2013-05-09T12:45:44Z</dc:date>
    </item>
    <item>
      <title>Re: Sum of Different Date Ranges</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-of-Different-Date-Ranges/m-p/443314#M485406</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can't easily use set analysis expressions in this case. The sets are calculated per chart, not per row. So you get one set for all the stores instead of a set per store like you want. You can use if statements instead. Something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #737373; font-family: Arial; background-color: #ffffff;"&gt;Sum( if (POSDate &amp;gt;= $(vMinSIRDate) and POSDATE &amp;lt;= max(RunDate),SalesDol))&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 May 2013 13:06:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-of-Different-Date-Ranges/m-p/443314#M485406</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2013-05-09T13:06:53Z</dc:date>
    </item>
    <item>
      <title>Re: Sum of Different Date Ranges</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-of-Different-Date-Ranges/m-p/443315#M485407</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Great, thank you Gysbert!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had to make some slight modifications, but that was the answer I was looking for.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sum(If(POSDate &amp;gt;= Date($(vMinSIRDate)) and POSDate &amp;lt;= Date(RunDate),Aggr(Max(SalesDol),ItemKey,POSDate)))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Without the aggregation and max on the sales dollars, I was getting extremely high numbers--multiple rows were being summed for each ItemKey/POSDate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ben D.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 May 2013 15:08:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-of-Different-Date-Ranges/m-p/443315#M485407</guid>
      <dc:creator />
      <dc:date>2013-05-09T15:08:13Z</dc:date>
    </item>
  </channel>
</rss>

