<?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: Detect longest pause between start/end time stamps. in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Detect-longest-pause-between-start-end-time-stamps/m-p/1728001#M55497</link>
    <description>&lt;P&gt;Make sure that your Date fields are in proper timestamp format Then you can try below&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Data:
LOAD
    EmpID,
    StampID,
    StartDateTime,
    EndDateTime,
    Department,
    "Rest Hours"
FROM [lib://Qlik]
(html, utf8, embedded labels, table is @2);

New:
NoConcatenate
Load *,
     peek(EndDateTime) as End,
     if(Peek(EmpID)=EmpID,
     round((StartDateTime-peek(EndDateTime))*24,0.01)) as Rest_Hour
Resident Data
Order by EmpID,StartDateTime;

Drop Table Data;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Jul 2020 12:16:16 GMT</pubDate>
    <dc:creator>Kushal_Chawda</dc:creator>
    <dc:date>2020-07-15T12:16:16Z</dc:date>
    <item>
      <title>Detect longest pause between start/end time stamps.</title>
      <link>https://community.qlik.com/t5/App-Development/Detect-longest-pause-between-start-end-time-stamps/m-p/1727963#M55493</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm looking at generating data based on time stamps. I'm looking at measuring the amount of time between a Stop and a Start (to see how long there has been a pause) on the next day per EmpID. Primarily to check that there has been minmum X numbers of hours.&lt;BR /&gt;&lt;BR /&gt;Data set example (simple) (column Rest is one I've added to visualize the figure I'm looking for, and which I'd ideally want as a scripted column, not Set Analytics. It also refers to the diff between StartDateTime&amp;nbsp; and previous EndDateTime, hence no number for first column)&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="10%" height="24px"&gt;EmpID&lt;/TD&gt;&lt;TD width="10%"&gt;StampID&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;StartDateTime&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;EndDateTime&lt;/TD&gt;&lt;TD width="10%" height="24px"&gt;Department&lt;/TD&gt;&lt;TD width="10%"&gt;Rest Hours&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="10%" height="46px"&gt;ID1&lt;/TD&gt;&lt;TD width="10%"&gt;77776&lt;/TD&gt;&lt;TD width="20%" height="46px"&gt;2020-06-25 06:00:00&lt;/TD&gt;&lt;TD width="20%" height="46px"&gt;2020-06-25 14:00:00&lt;/TD&gt;&lt;TD width="10%" height="46px"&gt;A123&lt;/TD&gt;&lt;TD width="10%"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="10%" height="46px"&gt;ID1&lt;/TD&gt;&lt;TD width="10%"&gt;77777&lt;/TD&gt;&lt;TD width="20%" height="46px"&gt;2020-06-26 12:00:00&lt;/TD&gt;&lt;TD width="20%" height="46px"&gt;2020-06-26 21:00:00&lt;/TD&gt;&lt;TD width="10%" height="46px"&gt;A123&lt;/TD&gt;&lt;TD width="10%"&gt;22&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="10%" height="46px"&gt;ID1&lt;/TD&gt;&lt;TD width="10%"&gt;66577&lt;/TD&gt;&lt;TD width="20%" height="46px"&gt;2020-06-27 06:00:00&lt;/TD&gt;&lt;TD width="20%" height="46px"&gt;2020-06-27 14:00:00&lt;/TD&gt;&lt;TD width="10%" height="46px"&gt;A123&lt;/TD&gt;&lt;TD width="10%"&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So for example in the example above the it measures the EndDateTime of the previous day to the StartDayTime of the next day. This isn't rocket science and something I can solve pretty easily.&lt;BR /&gt;&lt;BR /&gt;My question is how to handle example with multiple stamps per day. Here I really want to check between each End and Start for each ID within each instance. Each StampID is unique and only belowns to one EmpID.&lt;BR /&gt;&lt;BR /&gt;Advanced example (again, the Rest column is not in the data set, but visualization of the figure I'm looking for)&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="10%" height="24px"&gt;EmpID&lt;/TD&gt;&lt;TD width="10%" height="24px"&gt;StampID&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;StartDateTime&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;EndDateTime&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;Department&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;Rest Hours&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="10%" height="24px"&gt;ID1&lt;/TD&gt;&lt;TD width="10%" height="24px"&gt;55555&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;2020-06-25 06:00:00&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;2020-06-25 08:00:00&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;A132&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="10%" height="24px"&gt;ID1&lt;/TD&gt;&lt;TD width="10%" height="24px"&gt;55556&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;2020-06-25 11:00:00&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;2020-06-25 12:00:00&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;A123&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="10%" height="24px"&gt;ID1&lt;/TD&gt;&lt;TD width="10%" height="24px"&gt;55557&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;2020-06-25 12:00:00&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;2020-06-25 15:00:00&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;A222&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="10%" height="24px"&gt;ID1&lt;/TD&gt;&lt;TD width="10%" height="24px"&gt;55558&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;2020-06-25 20:00:00&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;2020-06-25 22:00:00&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;A123&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="10%" height="24px"&gt;ID1&lt;/TD&gt;&lt;TD width="10%" height="24px"&gt;88888&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;2020-06-26 10:00:00&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;2020-06-26 16:00:00&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;A132&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;12&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="10%" height="24px"&gt;ID1&lt;/TD&gt;&lt;TD width="10%" height="24px"&gt;88878&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;2020-06-26 19:00:00&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;2020-06-26 19:30:00&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;A555&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="10%" height="24px"&gt;ID1&lt;/TD&gt;&lt;TD width="10%" height="24px"&gt;99978&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;2020-06-27 06:00:00&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;2020-06-27 08:00:00&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;A123&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;10,5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="10%" height="24px"&gt;ID1&lt;/TD&gt;&lt;TD width="10%" height="24px"&gt;55664&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;2020-06-28 21:00:00&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;2020-06-29 04:00:00&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;A123&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;37&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="10%" height="24px"&gt;ID1&lt;/TD&gt;&lt;TD width="10%" height="24px"&gt;12345&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;2020-06-29 18:00:00&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;2020-06-29 06:00:00&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;A123&lt;/TD&gt;&lt;TD width="20%" height="24px"&gt;14&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;(The department will just be a reporting dimension)&lt;BR /&gt;Is there an somewhat easy way to do this? There is no real way to use the StampIDs to check the next one, they are unique but the next number might not be on that EmpID.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I understand the logic needed (While EmpID = ID1 select NextStartTimeDate, Rest = NextStartTimeDate - CurrentEndTimeDate) but now how to do it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Dec 2021 21:08:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Detect-longest-pause-between-start-end-time-stamps/m-p/1727963#M55493</guid>
      <dc:creator>OysteinT</dc:creator>
      <dc:date>2021-12-20T21:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: Detect longest pause between start/end time stamps.</title>
      <link>https://community.qlik.com/t5/App-Development/Detect-longest-pause-between-start-end-time-stamps/m-p/1728001#M55497</link>
      <description>&lt;P&gt;Make sure that your Date fields are in proper timestamp format Then you can try below&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Data:
LOAD
    EmpID,
    StampID,
    StartDateTime,
    EndDateTime,
    Department,
    "Rest Hours"
FROM [lib://Qlik]
(html, utf8, embedded labels, table is @2);

New:
NoConcatenate
Load *,
     peek(EndDateTime) as End,
     if(Peek(EmpID)=EmpID,
     round((StartDateTime-peek(EndDateTime))*24,0.01)) as Rest_Hour
Resident Data
Order by EmpID,StartDateTime;

Drop Table Data;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 12:16:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Detect-longest-pause-between-start-end-time-stamps/m-p/1728001#M55497</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2020-07-15T12:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: Detect longest pause between start/end time stamps.</title>
      <link>https://community.qlik.com/t5/App-Development/Detect-longest-pause-between-start-end-time-stamps/m-p/1728272#M55519</link>
      <description>&lt;P&gt;Awesome, this works perfectly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="OysteinT_0-1594883747459.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/37499i3296665D541FB75D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="OysteinT_0-1594883747459.png" alt="OysteinT_0-1594883747459.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 07:16:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Detect-longest-pause-between-start-end-time-stamps/m-p/1728272#M55519</guid>
      <dc:creator>OysteinT</dc:creator>
      <dc:date>2020-07-16T07:16:11Z</dc:date>
    </item>
  </channel>
</rss>

