<?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 Calculation based on dynamic range in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Calculation-based-on-dynamic-range/m-p/233575#M85112</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;MIght just have cracked it myself, actually.&lt;/P&gt;&lt;P&gt;I thought that maybe I needed to use aggregation within the calculation to allow Qlikview to get the correct max date per customer. I came up with this:&lt;/P&gt;&lt;P&gt;sum(&lt;/P&gt;&lt;P&gt;if(date#(Text(InvoiceDate),'YYYYMMDD')&amp;lt;=date#(aggr(nodistinct maxstring(text(InvoiceDate)),customer),'YYYYMMDD')-366,&lt;/P&gt;&lt;P&gt;Invoiceamount,&lt;/P&gt;&lt;P&gt;0)&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 06 May 2010 15:54:03 GMT</pubDate>
    <dc:creator />
    <dc:date>2010-05-06T15:54:03Z</dc:date>
    <item>
      <title>Calculation based on dynamic range</title>
      <link>https://community.qlik.com/t5/QlikView/Calculation-based-on-dynamic-range/m-p/233574#M85111</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 am trying to write a report to display the amount of spend by a customer in the 12 month period previous to their last paid invoice. The date of the last paid invoice will obviously be different for every customer, so I was hoping to use an if statement something along the lines of this:&lt;/P&gt;&lt;P&gt;sum(if(date(InvoiceDate,'YYYYMMDD')&amp;gt;&lt;BR /&gt;date(date#(text(max(InvoiceDate)),'YYYYMMDD')-366,'YYYYMMDD')&lt;BR /&gt;,InvoiceAmount,0))&lt;/P&gt;&lt;P&gt;I can get Qlikview to calculate the last invoice date per customer easily enough but when I try to use that value in an expression it give me a null answer. Has anyone achieved this sort of calculation before?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks,&lt;/P&gt;&lt;P&gt;N&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 May 2010 15:30:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculation-based-on-dynamic-range/m-p/233574#M85111</guid>
      <dc:creator />
      <dc:date>2010-05-06T15:30:21Z</dc:date>
    </item>
    <item>
      <title>Calculation based on dynamic range</title>
      <link>https://community.qlik.com/t5/QlikView/Calculation-based-on-dynamic-range/m-p/233575#M85112</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;MIght just have cracked it myself, actually.&lt;/P&gt;&lt;P&gt;I thought that maybe I needed to use aggregation within the calculation to allow Qlikview to get the correct max date per customer. I came up with this:&lt;/P&gt;&lt;P&gt;sum(&lt;/P&gt;&lt;P&gt;if(date#(Text(InvoiceDate),'YYYYMMDD')&amp;lt;=date#(aggr(nodistinct maxstring(text(InvoiceDate)),customer),'YYYYMMDD')-366,&lt;/P&gt;&lt;P&gt;Invoiceamount,&lt;/P&gt;&lt;P&gt;0)&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 May 2010 15:54:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculation-based-on-dynamic-range/m-p/233575#M85112</guid>
      <dc:creator />
      <dc:date>2010-05-06T15:54:03Z</dc:date>
    </item>
  </channel>
</rss>

