<?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: Time difference between two rows in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Time-difference-between-two-rows/m-p/816413#M287941</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try a simpler version to start with to return the variance in seconds:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD Num, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date - peek(Date) as Datevar,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 24*60*60*(Date - peek(Date)) as DatevarSec&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;etc&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This seems to work with your figures.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 17 Mar 2015 11:04:19 GMT</pubDate>
    <dc:creator>Roop</dc:creator>
    <dc:date>2015-03-17T11:04:19Z</dc:date>
    <item>
      <title>Time difference between two rows</title>
      <link>https://community.qlik.com/t5/QlikView/Time-difference-between-two-rows/m-p/816410#M287938</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying tow calculate the time difference between two rows.&amp;nbsp; Below is my script for the two fields.&amp;nbsp; Im also sorting correctly, but still dont get the proper durations.&amp;nbsp; PLEASE HELP !!!!???&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INCIDENT_MAIN_NEW:&lt;/P&gt;&lt;P&gt;LOAD &lt;/P&gt;&lt;P&gt;&amp;nbsp; *,&lt;/P&gt;&lt;P&gt;&amp;nbsp; If(ParentLink_RecID = Peek(ParentLink_RecID), Peek(CreatedDateTime_Step) - CreatedDateTime_Step&lt;/P&gt;&lt;P&gt;&amp;nbsp; ,If(Status = 'CLOSED', Interval(ClosedDateTime - CreatedDateTime_Step, 'D hh:mm'), Interval(NOw(1) - CreatedDateTime_Step, 'D hh:mm')&lt;/P&gt;&lt;P&gt;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&amp;nbsp; ) As Step_Duration,&lt;/P&gt;&lt;P&gt;&amp;nbsp; If(ParentLink_RecID = Peek(ParentLink_RecID), Peek(CreatedDateTime_Step) - CreatedDateTime_Step&lt;/P&gt;&lt;P&gt;&amp;nbsp; ,If(Status = 'CLOSED', Interval(ClosedDateTime - CreatedDateTime_Step, 'D'), Interval(NOw(1) - CreatedDateTime_Step, 'D')&lt;/P&gt;&lt;P&gt;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&amp;nbsp; ) &lt;/P&gt;&lt;P&gt;&amp;nbsp; As Step_Duration_Days&lt;/P&gt;&lt;P&gt; Resident INCIDENT&lt;/P&gt;&lt;P&gt;ORDER BY IncidentNumber, CreatedDateTime_Step ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 10:37:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Time-difference-between-two-rows/m-p/816410#M287938</guid>
      <dc:creator />
      <dc:date>2015-03-17T10:37:09Z</dc:date>
    </item>
    <item>
      <title>Re: Time difference between two rows</title>
      <link>https://community.qlik.com/t5/QlikView/Time-difference-between-two-rows/m-p/816411#M287939</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Would you be able to give an example (may be couple of rows of data) with what you got and what you expect to get.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;S&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 10:40:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Time-difference-between-two-rows/m-p/816411#M287939</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2015-03-17T10:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: Time difference between two rows</title>
      <link>https://community.qlik.com/t5/QlikView/Time-difference-between-two-rows/m-p/816412#M287940</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi S&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is ONE incident.&amp;nbsp; Im getting rubbish data back.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 380px;"&gt;&lt;TBODY&gt;&lt;TR style="mso-height-source: userset; height: 22.5pt;"&gt;&lt;TD class="xl66" height="30" style="height: 22.5pt; width: 48pt;" width="64"&gt;IncidentNumber&lt;/TD&gt;&lt;TD class="xl66" style="border-left: none; width: 93pt;" width="124"&gt;CreatedDateTime_Step&lt;/TD&gt;&lt;TD class="xl66" style="border-left: none; width: 56pt;" width="75"&gt;Step Duration&lt;/TD&gt;&lt;TD class="xl66" style="border-left: none; width: 88pt;" width="117"&gt;Step_Duration_Days&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD align="right" class="xl67" height="20" style="height: 15.0pt; border-top: none;"&gt;724695&lt;/TD&gt;&lt;TD align="right" class="xl68" style="border-top: none; border-left: none;"&gt;22/12/2011 13:27&lt;/TD&gt;&lt;TD class="xl69" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD class="xl70" style="border-top: none; border-left: none;"&gt;-0.16685185185634&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD align="right" class="xl67" height="20" style="height: 15.0pt; border-top: none;"&gt;724695&lt;/TD&gt;&lt;TD align="right" class="xl68" style="border-top: none; border-left: none;"&gt;22/12/2011 13:30&lt;/TD&gt;&lt;TD class="xl69" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD class="xl70" style="border-top: none; border-left: none;"&gt;-0.0025231481413357&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD align="right" class="xl67" height="20" style="height: 15.0pt; border-top: none;"&gt;724695&lt;/TD&gt;&lt;TD align="right" class="xl68" style="border-top: none; border-left: none;"&gt;22/12/2011 09:27&lt;/TD&gt;&lt;TD class="xl69" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD class="xl70" style="border-top: none; border-left: none;"&gt;1181&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD align="right" class="xl67" height="20" style="height: 15.0pt; border-top: none;"&gt;724695&lt;/TD&gt;&lt;TD align="right" class="xl68" style="border-top: none; border-left: none;"&gt;01/12/2012 12:33&lt;/TD&gt;&lt;TD class="xl71" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD class="xl70" style="border-top: none; border-left: none;"&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 10:47:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Time-difference-between-two-rows/m-p/816412#M287940</guid>
      <dc:creator />
      <dc:date>2015-03-17T10:47:47Z</dc:date>
    </item>
    <item>
      <title>Re: Time difference between two rows</title>
      <link>https://community.qlik.com/t5/QlikView/Time-difference-between-two-rows/m-p/816413#M287941</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try a simpler version to start with to return the variance in seconds:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD Num, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date - peek(Date) as Datevar,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 24*60*60*(Date - peek(Date)) as DatevarSec&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;etc&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This seems to work with your figures.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 11:04:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Time-difference-between-two-rows/m-p/816413#M287941</guid>
      <dc:creator>Roop</dc:creator>
      <dc:date>2015-03-17T11:04:19Z</dc:date>
    </item>
    <item>
      <title>Re: Time difference between two rows</title>
      <link>https://community.qlik.com/t5/QlikView/Time-difference-between-two-rows/m-p/816414#M287942</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Rupert&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've given that a try.&amp;nbsp; BUt no luck.&amp;nbsp; I might be doing something wrong somewhere&amp;nbsp; &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/sad.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 12:05:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Time-difference-between-two-rows/m-p/816414#M287942</guid>
      <dc:creator />
      <dc:date>2015-03-17T12:05:16Z</dc:date>
    </item>
    <item>
      <title>Re: Time difference between two rows</title>
      <link>https://community.qlik.com/t5/QlikView/Time-difference-between-two-rows/m-p/816415#M287943</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you include your script that you are trying again?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 12:06:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Time-difference-between-two-rows/m-p/816415#M287943</guid>
      <dc:creator>Roop</dc:creator>
      <dc:date>2015-03-17T12:06:58Z</dc:date>
    </item>
    <item>
      <title>Re: Time difference between two rows</title>
      <link>https://community.qlik.com/t5/QlikView/Time-difference-between-two-rows/m-p/816416#M287944</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bradley,&lt;/P&gt;&lt;P&gt;This: Peek(CreatedDateTime_Step) - CreatedDateTime_Step&lt;/P&gt;&lt;P&gt;Should be: CreatedDateTime_Step - Peek(CreatedDateTime_Step)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And not sure but maybe ParentLink_RecID should be on Order By.&lt;/P&gt;&lt;P&gt;Or change the "If(ParentLink_RecID = Peek(ParentLink_RecID)" to&lt;/P&gt;&lt;P&gt;If(IncidentNumber=Peek(IncidentNumber)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 12:15:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Time-difference-between-two-rows/m-p/816416#M287944</guid>
      <dc:creator>rubenmarin</dc:creator>
      <dc:date>2015-03-17T12:15:45Z</dc:date>
    </item>
    <item>
      <title>Re: Time difference between two rows</title>
      <link>https://community.qlik.com/t5/QlikView/Time-difference-between-two-rows/m-p/816417#M287945</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;IMG alt="1.png" class="image-1 jive-image" src="https://community.qlik.com/legacyfs/online/80967_1.png" style="height: auto; width: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try this&lt;/P&gt;&lt;P&gt;&lt;EM&gt;a:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;load *, date#(CreatedDateTime_Step, 'DD/MM/YYYY hh:mm')&amp;nbsp; as d inline [&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;IncidentNumber, CreatedDateTime_Step, Step Duration, Step_Duration_Days&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;724695, 22/12/2011 13:27, -0.16685185185634&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;724695, 22/12/2011 13:30, -0.0025231481413357&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;724695, 22/12/2011 09:27, 1181&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;724695, 01/12/2012 12:33, -&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;];&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;b:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;load &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; d,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; d - Peek(d) as Duration,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; floor(d - Peek(d)) as DurationD,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; interval(frac(d - Peek(d))) as DurationS&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Resident a&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;order by d;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;DROP Table a;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 12:23:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Time-difference-between-two-rows/m-p/816417#M287945</guid>
      <dc:creator>maxgro</dc:creator>
      <dc:date>2015-03-17T12:23:43Z</dc:date>
    </item>
  </channel>
</rss>

