<?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 Re: Calculating the hours ago from the max timestamp per object? in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Calculating-the-hours-ago-from-the-max-timestamp-per-object/m-p/1556706#M40451</link>
    <description>&lt;P&gt;Hi Rob,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. The MaxFinderByObject step takes 1 hour. The entire reload takes 1 hour and 30 minutes.&lt;/P&gt;&lt;P&gt;2. I have ~16,000 Objects&lt;/P&gt;&lt;P&gt;3. We are currently on version April 2018&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;S&lt;/P&gt;</description>
    <pubDate>Thu, 14 Mar 2019 16:38:39 GMT</pubDate>
    <dc:creator>Sazabi</dc:creator>
    <dc:date>2019-03-14T16:38:39Z</dc:date>
    <item>
      <title>Calculating the hours ago from the max timestamp per object?</title>
      <link>https://community.qlik.com/t5/App-Development/Calculating-the-hours-ago-from-the-max-timestamp-per-object/m-p/1556233#M40306</link>
      <description>&lt;P&gt;Salutations Qlik Compadres.&lt;/P&gt;&lt;P&gt;I am looking to return how many hours ago a row is from the max timestamp per object.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;PRE&gt;+---------------------+--------+----------+
| Timestamp           | Object | HoursAgo |
+---------------------+--------+----------+
| 2019-02-01 10:00:00 | A      | 0        |
+---------------------+--------+----------+
| 2019-02-01 09:00:00 | A      | 1        |
+---------------------+--------+----------+
| 2019-02-01 08:00:00 | A      | 2        |
+---------------------+--------+----------+
| 2019-02-01 10:00:00 | B      | 0        |
+---------------------+--------+----------+
| 2019-02-01 09:00:00 | B      | 1        |
+---------------------+--------+----------+
| 2019-02-01 08:00:00 | B      | 2        |
+---------------------+--------+----------+
| 2019-01-01 14:00:00 | C      | 0        |
+---------------------+--------+----------+
| 2019-01-01 13:00:00 | C      | 1        |
+---------------------+--------+----------+
| 2019-01-01 12:00:00 | C      | 2        |
+---------------------+--------+----------+&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Object A's latest timestamp is&amp;nbsp; [2019-02-01 10:00:00] which is 0 hours ago.&lt;/P&gt;&lt;P&gt;The timestamp after that is [2019-02-01 09:00:00]&amp;nbsp;which is 1 hour ago, etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Object C's latest timestamp is [2019-01-01 14:00:00], but the HoursAgo value is 0. This is because that timestamp is the latest for that object.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thoughts on how I can implement this?&lt;/P&gt;&lt;P&gt;I tried loading in my fact tables, finding the max timestamp per object, then calculating out the HoursAgo value in the data load editor, but it takes an hour to do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyone know a better way?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;S&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2019 20:05:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calculating-the-hours-ago-from-the-max-timestamp-per-object/m-p/1556233#M40306</guid>
      <dc:creator>Sazabi</dc:creator>
      <dc:date>2019-03-13T20:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating the hours ago from the max timestamp per object?</title>
      <link>https://community.qlik.com/t5/App-Development/Calculating-the-hours-ago-from-the-max-timestamp-per-object/m-p/1556267#M40344</link>
      <description>&lt;P&gt;It should be relatively quick to compute it in the script. How many rows are in your fact table?&amp;nbsp; Can you post the script you tried?&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2019 21:28:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calculating-the-hours-ago-from-the-max-timestamp-per-object/m-p/1556267#M40344</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2019-03-13T21:28:47Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating the hours ago from the max timestamp per object?</title>
      <link>https://community.qlik.com/t5/App-Development/Calculating-the-hours-ago-from-the-max-timestamp-per-object/m-p/1556272#M40349</link>
      <description>&lt;P&gt;Hi Rob!&lt;/P&gt;&lt;P&gt;We are pulling in 30 QVD files (1 per day), resulting in 11.6 million rows of data in our fact table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What we do in the script is:&lt;/P&gt;&lt;P&gt;1. Loop through and load each individual QVD file (optimized load)&lt;/P&gt;&lt;P&gt;2. After everything is loaded,&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;-- find the max timestamp per object and join it back to fact&lt;BR /&gt;MaxFinderByObject:
Load Object, max(timestamp) as maxTimestamp Resident FactTable 
group by Object;
join
Load * Resident FactTable;
&lt;BR /&gt;-- does the calculation to find the hours ago from max timestamp per object.
FactTable_HoursAgo_Calculated:
load interval(maxTimestamp - timestamp, 'h') as HoursAgo, * Resident MaxFinderByObject;

drop table MaxFinderByObject, FactTable;
drop field maxTimestamp;&lt;/PRE&gt;&lt;P&gt;This process takes 1 hour.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2019 21:41:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calculating-the-hours-ago-from-the-max-timestamp-per-object/m-p/1556272#M40349</guid>
      <dc:creator>Sazabi</dc:creator>
      <dc:date>2019-03-13T21:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating the hours ago from the max timestamp per object?</title>
      <link>https://community.qlik.com/t5/App-Development/Calculating-the-hours-ago-from-the-max-timestamp-per-object/m-p/1556663#M40433</link>
      <description>&lt;P&gt;A few more questions:&lt;/P&gt;&lt;P&gt;1. How much time of the hour is taken by the MaxFinderByObject step?&lt;/P&gt;&lt;P&gt;2. I'm guessing you have a lot of Object values, about how many?&lt;/P&gt;&lt;P&gt;3. What version of Qlik?&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2019 15:52:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calculating-the-hours-ago-from-the-max-timestamp-per-object/m-p/1556663#M40433</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2019-03-14T15:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating the hours ago from the max timestamp per object?</title>
      <link>https://community.qlik.com/t5/App-Development/Calculating-the-hours-ago-from-the-max-timestamp-per-object/m-p/1556706#M40451</link>
      <description>&lt;P&gt;Hi Rob,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. The MaxFinderByObject step takes 1 hour. The entire reload takes 1 hour and 30 minutes.&lt;/P&gt;&lt;P&gt;2. I have ~16,000 Objects&lt;/P&gt;&lt;P&gt;3. We are currently on version April 2018&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;S&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2019 16:38:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calculating-the-hours-ago-from-the-max-timestamp-per-object/m-p/1556706#M40451</guid>
      <dc:creator>Sazabi</dc:creator>
      <dc:date>2019-03-14T16:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating the hours ago from the max timestamp per object?</title>
      <link>https://community.qlik.com/t5/App-Development/Calculating-the-hours-ago-from-the-max-timestamp-per-object/m-p/1556936#M40542</link>
      <description>&lt;P&gt;Group by when you have a lot of values can be a killer. Some things you might test to see if they perform better.&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Sort the fact table by Object before the group by. Or add an "order by Object" to your current MaxFinderByObject load.&lt;/P&gt;&lt;P&gt;2.&amp;nbsp; Instead of max() and group by, use sorting:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;FactTable2:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;Load *,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; if(Object = Previous(Object), peek('MaxTimestamp'), timestamp) as MaxTimestamp&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;Resident FactTable&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;Order by Object, timestamp DESC;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;Drop Table FactTable;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;-Rob&lt;BR /&gt;&lt;A href="http://masterssummit.com" target="_blank"&gt;http://masterssummit.com&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://qlikviewcookbook.com" target="_blank"&gt;http://qlikviewcookbook.com&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.easyqlik.com" target="_blank"&gt;http://www.easyqlik.com&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2019 07:12:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calculating-the-hours-ago-from-the-max-timestamp-per-object/m-p/1556936#M40542</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2019-03-15T07:12:19Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating the hours ago from the max timestamp per object?</title>
      <link>https://community.qlik.com/t5/App-Development/Calculating-the-hours-ago-from-the-max-timestamp-per-object/m-p/1558674#M40693</link>
      <description>&lt;P&gt;Hi Rob,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the response &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I agree that the group by + resident load seems to be the killer here &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I tried your latest recommended method and the reload time took 1 hour and 58 minutes, with most of the time being in the group by + resident.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm thinking of incrementally creating a QVD file per day containing the max(timestamp) per object per day. Then, I would load those files into the app and determine the max(timestamp) per object. Then, I can leave the table containing the object and the most max(timestamp) in as a reference table. (or even applymap!)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my mind, this process should be much quicker because we are applying the group by + resident load and sorting on a much smaller sample size.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I don't like is the added complexity...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thoughts?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;S&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2019 22:49:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calculating-the-hours-ago-from-the-max-timestamp-per-object/m-p/1558674#M40693</guid>
      <dc:creator>Sazabi</dc:creator>
      <dc:date>2019-03-19T22:49:09Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating the hours ago from the max timestamp per object?</title>
      <link>https://community.qlik.com/t5/App-Development/Calculating-the-hours-ago-from-the-max-timestamp-per-object/m-p/1559734#M40767</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;I tried your latest recommended method and the reload time took 1 hour and 58 minutes, with most of the time being in the group by + resident."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I don't understand. My recommendation #2 did not use a group by. Did you try #2?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;-Rob&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2019 17:21:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calculating-the-hours-ago-from-the-max-timestamp-per-object/m-p/1559734#M40767</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2019-03-21T17:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating the hours ago from the max timestamp per object?</title>
      <link>https://community.qlik.com/t5/App-Development/Calculating-the-hours-ago-from-the-max-timestamp-per-object/m-p/1559736#M40769</link>
      <description>&lt;P&gt;Oh sorry,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I typed into the forum post "group by", but I really put "order by" in the load script&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;S&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2019 17:25:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calculating-the-hours-ago-from-the-max-timestamp-per-object/m-p/1559736#M40769</guid>
      <dc:creator>Sazabi</dc:creator>
      <dc:date>2019-03-21T17:25:31Z</dc:date>
    </item>
  </channel>
</rss>

