<?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 Filter only last version of historical data in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Filter-only-last-version-of-historical-data/m-p/1829819#M68390</link>
    <description>&lt;P&gt;Dear all&lt;/P&gt;&lt;P&gt;I'm quite new in the community, and I have a problem for which I've not found any answer.&lt;/P&gt;&lt;P&gt;I use QlikSense Cloud App for dashboarding data from a CRM. Every day, the data is extracted from the CRM and updated.&lt;/P&gt;&lt;P&gt;Hence, I may have multiple rows for each business lead, each time it is updated.&lt;/P&gt;&lt;P&gt;For instance, here is an exemple :&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ID &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| STATUS &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| UPDATE_DATE &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| VALUE&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| qualification &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 2021/08/19 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 10000&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| qualification &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 2021/08/19 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 5000&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | forecast. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | 2021/08/03 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 2000&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | forecast. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | 2021/07/23 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 8000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My need is to have&amp;nbsp;&lt;/P&gt;&lt;P&gt;1/ A table with SUM(VALUE) for each STATUS at the current date (now). hence if we are August, 19th&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; qualification --&amp;gt; 10000 + 5000 = 15000&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; forecast --&amp;gt; 8000 (do not take into account the 2000 line, as it has already been taken into account in qualification)&lt;/P&gt;&lt;P&gt;2/ A table with SUM(VALUE) for each STATUS at any date, as I could want to have a historical view of my CRM. Of course, new data updates should then be ignored.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried different versions of FIRSTSORTEDVALUE and AGGR, but nothing worked.&amp;nbsp;&lt;/P&gt;&lt;P&gt;One thing is the we cannot "think" only at the STATUS level, as otherwise my ID 1 lead above would be counted twice. It seems I would need a global filter selecting only the "last" version of each row, and a ability to set a date for the "last" parameter.&lt;/P&gt;&lt;P&gt;What do you think ?&lt;/P&gt;&lt;P&gt;Many thanks.&lt;/P&gt;</description>
    <pubDate>Thu, 19 Aug 2021 14:15:25 GMT</pubDate>
    <dc:creator>_Julien_</dc:creator>
    <dc:date>2021-08-19T14:15:25Z</dc:date>
    <item>
      <title>Filter only last version of historical data</title>
      <link>https://community.qlik.com/t5/App-Development/Filter-only-last-version-of-historical-data/m-p/1829819#M68390</link>
      <description>&lt;P&gt;Dear all&lt;/P&gt;&lt;P&gt;I'm quite new in the community, and I have a problem for which I've not found any answer.&lt;/P&gt;&lt;P&gt;I use QlikSense Cloud App for dashboarding data from a CRM. Every day, the data is extracted from the CRM and updated.&lt;/P&gt;&lt;P&gt;Hence, I may have multiple rows for each business lead, each time it is updated.&lt;/P&gt;&lt;P&gt;For instance, here is an exemple :&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ID &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| STATUS &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| UPDATE_DATE &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| VALUE&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| qualification &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 2021/08/19 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 10000&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| qualification &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 2021/08/19 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 5000&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | forecast. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | 2021/08/03 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 2000&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | forecast. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | 2021/07/23 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 8000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My need is to have&amp;nbsp;&lt;/P&gt;&lt;P&gt;1/ A table with SUM(VALUE) for each STATUS at the current date (now). hence if we are August, 19th&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; qualification --&amp;gt; 10000 + 5000 = 15000&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; forecast --&amp;gt; 8000 (do not take into account the 2000 line, as it has already been taken into account in qualification)&lt;/P&gt;&lt;P&gt;2/ A table with SUM(VALUE) for each STATUS at any date, as I could want to have a historical view of my CRM. Of course, new data updates should then be ignored.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried different versions of FIRSTSORTEDVALUE and AGGR, but nothing worked.&amp;nbsp;&lt;/P&gt;&lt;P&gt;One thing is the we cannot "think" only at the STATUS level, as otherwise my ID 1 lead above would be counted twice. It seems I would need a global filter selecting only the "last" version of each row, and a ability to set a date for the "last" parameter.&lt;/P&gt;&lt;P&gt;What do you think ?&lt;/P&gt;&lt;P&gt;Many thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2021 14:15:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Filter-only-last-version-of-historical-data/m-p/1829819#M68390</guid>
      <dc:creator>_Julien_</dc:creator>
      <dc:date>2021-08-19T14:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: Filter only last version of historical data</title>
      <link>https://community.qlik.com/t5/App-Development/Filter-only-last-version-of-historical-data/m-p/1829888#M68391</link>
      <description>&lt;P&gt;You could solve this with interval match. Take a look at this script.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="3"&gt;SET DateFormat='YYYY/MM/DD';&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="3"&gt;RAW:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="3"&gt;LOAD * inline [&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="3"&gt;ID, STATUS, UPDATE_DATE, VALUE&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="3"&gt;1, qualification, 2021/08/18, 10000&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="3"&gt;2, qualification, 2021/08/18, 5000&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="3"&gt;1, forecast., 2021/08/03, 2000&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="3"&gt;3, forecast., 2021/07/23, 8000&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="3"&gt;]&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="3"&gt;;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="3"&gt;Data:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="3"&gt;LOAD ID, STATUS, UPDATE_DATE as Date_from,VALUE, if(ID=Peek(ID),DayEnd( Peek(Date_from),-1), dayend(today())) as Date_to&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="3"&gt;Resident RAW&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="3"&gt;ORDER BY ID, UPDATE_DATE desc&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="3"&gt;LOAD &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="3"&gt;dayname(date#('2021/07/22')+RecNo()) as Date&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="3"&gt;AutoGenerate today() - date#('2021/07/22');&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;IntervalMatch(Date)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="3"&gt;LOAD Date_from,Date_to &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="3"&gt;Resident Data;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="3"&gt;DROP TABLE RAW;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2021 16:49:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Filter-only-last-version-of-historical-data/m-p/1829888#M68391</guid>
      <dc:creator>Vegar</dc:creator>
      <dc:date>2021-08-19T16:49:30Z</dc:date>
    </item>
    <item>
      <title>Re: Filter only last version of historical data</title>
      <link>https://community.qlik.com/t5/App-Development/Filter-only-last-version-of-historical-data/m-p/1830246#M68418</link>
      <description>&lt;P&gt;Hi Vegar&lt;/P&gt;&lt;P&gt;Thanks for your answer. I get inspiration from what you did, and here is what I finally did.&lt;/P&gt;&lt;P&gt;My data comes from "pipedrive", our CRM. So in the data load editor,&lt;/P&gt;&lt;P&gt;1/ I loaded the deals table, with only the fields I need : id, add_time (that is creation time) and update_time.&lt;/P&gt;&lt;P&gt;2/ I created one temporary table, 'deals_from_one_month_ago'. The only things that is done is to filter on "add_time", and to retrieve the last available version of the row, through the ID=Peek(ID) trick that you showed above.&lt;/P&gt;&lt;P&gt;3/ Now in my sheet, thanks to the magic of QlikSense that automatically handle foreign keys, I can select the relevant data based on the value on the two "TIMETRAVEL_ONEMONTHAGO" field.&lt;/P&gt;&lt;P&gt;Here is the script :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;LIB CONNECT TO [Google_BigQuery_acme-datawarehouse];

[deals_tempo]:
LOAD
    [id]
    [update_time]
    [add_time]
SELECT id,
    `update_time`,
    `add_time`,
FROM `pipedrive_acme.deals`;

[deals_from_one_month_ago]:
LOAD [id],[update_time], if([id]=Peek([id]),'NO', 'YES') as 'TIMETRAVEL_ONEMONTHAGO'
Resident [deals_tempo]
WHERE [add_time] &amp;lt;= date(Today()-30)
ORDER BY [id], [update_time] desc
;

DROP TABLE [deals_tempo];&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Of course I can create more tables to handle 2 months ago, now, and so on.&lt;/P&gt;&lt;P&gt;Julien&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 15:32:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Filter-only-last-version-of-historical-data/m-p/1830246#M68418</guid>
      <dc:creator>_Julien_</dc:creator>
      <dc:date>2021-08-20T15:32:57Z</dc:date>
    </item>
  </channel>
</rss>

