<?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: Dates between rows - Matching ID &amp;amp; Time - Interval/Peek/Min [Script][Sense] in Connectivity &amp; Data Prep</title>
    <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Dates-between-rows-Matching-ID-amp-Time-Interval-Peek-Min-Script/m-p/1554400#M3678</link>
    <description>Need a Group By for the Min()</description>
    <pubDate>Fri, 08 Mar 2019 18:27:53 GMT</pubDate>
    <dc:creator>dwforest</dc:creator>
    <dc:date>2019-03-08T18:27:53Z</dc:date>
    <item>
      <title>Dates between rows - Matching ID &amp; Time - Interval/Peek/Min [Script][Sense]</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Dates-between-rows-Matching-ID-amp-Time-Interval-Peek-Min-Script/m-p/1554145#M3673</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to get the state duration for the next table:&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Captura0.PNG" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/7591i359707344887F7B8/image-size/large?v=v2&amp;amp;px=999" role="button" title="Captura0.PNG" alt="Captura0.PNG" /&gt;&lt;/span&gt;I try to create a script where i can peek the minimum date where the resource ID match and the date is older than the one from the row, then I get the timestamp between the two dates. But I am getting an error. There my sample &amp;amp; Error (sorry about SPA):&lt;/P&gt;&lt;P&gt;SQL (guideline): select Min(eventdatetime) from agentstatedetail where agentstatedetail.resourceID equal&amp;nbsp;resourceID And&amp;nbsp;agentstatedetail.eventdatetime &amp;gt;=&amp;nbsp;eventdatetime;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="CapturaA.PNG" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/7593iC17D698E9615B497/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CapturaA.PNG" alt="CapturaA.PNG" /&gt;&lt;/span&gt;&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-center" image-alt="CapturaB.PNG" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/7594i07766FC648F51F66/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CapturaB.PNG" alt="CapturaB.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Anyone knows what I am missing? Error code is&amp;nbsp;as useful as windows problem solver. I am not able to modify the data source.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Dec 2021 15:17:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/Dates-between-rows-Matching-ID-amp-Time-Interval-Peek-Min-Script/m-p/1554145#M3673</guid>
      <dc:creator>coco832</dc:creator>
      <dc:date>2021-12-23T15:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dates between rows - Matching ID &amp; Time - Interval/Peek/Min [Script][Sense]</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Dates-between-rows-Matching-ID-amp-Time-Interval-Peek-Min-Script/m-p/1554400#M3678</link>
      <description>Need a Group By for the Min()</description>
      <pubDate>Fri, 08 Mar 2019 18:27:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/Dates-between-rows-Matching-ID-amp-Time-Interval-Peek-Min-Script/m-p/1554400#M3678</guid>
      <dc:creator>dwforest</dc:creator>
      <dc:date>2019-03-08T18:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: Dates between rows - Matching ID &amp; Time - Interval/Peek/Min [Script][Sense]</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Dates-between-rows-Matching-ID-amp-Time-Interval-Peek-Min-Script/m-p/1554793#M3682</link>
      <description>&lt;PRE&gt;[agentstatedetailB]:
LOAD
	[resourceid],
	[agentstatedetail.eventdatetime],
	Interval(if(Peek([resourceid])=[resourceid] And Peek([agentstatedetail.eventdatetime])&amp;gt;[agentstatedetail.eventdatetime],Min([agentstatedetail.eventdatetime]))-[agentstatedetail.eventdatetime]) AS [Duration] 
    Resident agentstatedetail Group By [agentstatedetail.eventdatetime]
    ;&lt;/PRE&gt;&lt;P&gt;Still getting the error.&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="errorqlik.PNG" style="width: 380px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/7696iFCC2B08E10FE1086/image-dimensions/380x389?v=v2" width="380" height="389" role="button" title="errorqlik.PNG" alt="errorqlik.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2019 12:00:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/Dates-between-rows-Matching-ID-amp-Time-Interval-Peek-Min-Script/m-p/1554793#M3682</guid>
      <dc:creator>coco832</dc:creator>
      <dc:date>2019-03-11T12:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: Dates between rows - Matching ID &amp; Time - Interval/Peek/Min [Script][Sense]</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Dates-between-rows-Matching-ID-amp-Time-Interval-Peek-Min-Script/m-p/1560865#M3751</link>
      <description>&lt;P&gt;After few day i was not able to find a direct solution using Qlik Script functions, there you got&amp;nbsp; a solution with SQL:&lt;/P&gt;&lt;P&gt;This is an inaccurate solution.&lt;/P&gt;&lt;PRE&gt;SQL SELECT mt.agentid,
	mt.eventdatetime,
	mt2.eventdatetime AS nexteventdatetime,
	mt2.eventdatetime - mt.eventdatetime AS stateduration
  FROM (
SELECT
	sd.agentid,
	sd.eventdatetime,
	ROW_NUMBER() OVER( ORDER BY sd.agentid ASC, sd.eventdatetime ASC) AS this_row_nr,
	( ROW_NUMBER() OVER( ORDER BY sd.agentid ASC, sd.eventdatetime ASC) ) + 1 AS next_row_nr
  FROM 
	informix.agentstatedetail	AS sd
) AS mt
  LEFT JOIN
(
SELECT
	sd.agentid,
	sd.eventdatetime,
	ROW_NUMBER() OVER( ORDER BY sd.agentid ASC, sd.eventdatetime ASC) AS this_row_nr,
	( ROW_NUMBER() OVER( ORDER BY sd.agentid ASC, sd.eventdatetime ASC) ) + 1 AS next_row_nr
  FROM 
	informix.agentstatedetail	AS sd
) AS mt2
    ON mt.agentid = mt2.agentid 
   AND mt.next_row_nr = mt2.this_row_nr;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Mar 2019 15:48:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/Dates-between-rows-Matching-ID-amp-Time-Interval-Peek-Min-Script/m-p/1560865#M3751</guid>
      <dc:creator>coco832</dc:creator>
      <dc:date>2019-03-25T15:48:27Z</dc:date>
    </item>
  </channel>
</rss>

