<?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: First sorted Value for min and max date for each ID in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/First-sorted-Value-for-min-and-max-date-for-each-ID/m-p/1679431#M727703</link>
    <description>&lt;P&gt;Does this help you:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Data:
load [PRIMARY ID], EVENTS , TIMESTAMP inline [
PRIMARY ID, EVENTS , 	TIMESTAMP
1,			Event 1.1,	2020-02-26 14:17:01
1,			Event 1.3,	2020-02-26 16:19:03
1,			Event 1.2,	2020-02-26 15:18:02
2,			Event 2.1,	2020-02-26 17:20:04
2,			Event 2.2,	2020-02-26 18:21:05
2,			Event 2.3,	2020-02-26 19:22:06
2,			Event 2.4,	2020-02-26 20:23:07
3,			Event 3.1,	2020-02-26 21:24:08
];


Output:
LOAD  
	[PRIMARY ID],
	max(TIMESTAMP) as TIMESTAMP,
	'Last' as Stage
Resident Data
group by 	[PRIMARY ID];
LOAD  
	[PRIMARY ID],
	'First' as Stage,
	min(TIMESTAMP) as TIMESTAMP
Resident Data
group by 	[PRIMARY ID];

LEFT join
 LOAD *
 Resident Data;
Drop Table Data;
Exit script&lt;/LI-CODE&gt;&lt;P&gt;It gives this output:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 563px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/29124iE6BD8B48ADD89A31/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 26 Feb 2020 12:21:18 GMT</pubDate>
    <dc:creator>Vegar</dc:creator>
    <dc:date>2020-02-26T12:21:18Z</dc:date>
    <item>
      <title>First sorted Value for min and max date for each ID</title>
      <link>https://community.qlik.com/t5/QlikView/First-sorted-Value-for-min-and-max-date-for-each-ID/m-p/1679412#M727700</link>
      <description>&lt;P&gt;I am very new to qlikview and trying to get my head around the first sorted value functionality.&lt;/P&gt;&lt;P&gt;My problem is i have 3 columns&amp;nbsp;&lt;/P&gt;&lt;P&gt;PRIMARY ID , EVENTS , TIMESTAMP&lt;/P&gt;&lt;P&gt;now i want to find for each primary ID the event at max and min time. Primary id is getting repeated as an id has to go through the lifecycle and i have to find the stage at max time and min time in same table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 01:11:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/First-sorted-Value-for-min-and-max-date-for-each-ID/m-p/1679412#M727700</guid>
      <dc:creator>Nathan22</dc:creator>
      <dc:date>2024-11-16T01:11:11Z</dc:date>
    </item>
    <item>
      <title>Re: First sorted Value for min and max date for each ID</title>
      <link>https://community.qlik.com/t5/QlikView/First-sorted-Value-for-min-and-max-date-for-each-ID/m-p/1679431#M727703</link>
      <description>&lt;P&gt;Does this help you:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Data:
load [PRIMARY ID], EVENTS , TIMESTAMP inline [
PRIMARY ID, EVENTS , 	TIMESTAMP
1,			Event 1.1,	2020-02-26 14:17:01
1,			Event 1.3,	2020-02-26 16:19:03
1,			Event 1.2,	2020-02-26 15:18:02
2,			Event 2.1,	2020-02-26 17:20:04
2,			Event 2.2,	2020-02-26 18:21:05
2,			Event 2.3,	2020-02-26 19:22:06
2,			Event 2.4,	2020-02-26 20:23:07
3,			Event 3.1,	2020-02-26 21:24:08
];


Output:
LOAD  
	[PRIMARY ID],
	max(TIMESTAMP) as TIMESTAMP,
	'Last' as Stage
Resident Data
group by 	[PRIMARY ID];
LOAD  
	[PRIMARY ID],
	'First' as Stage,
	min(TIMESTAMP) as TIMESTAMP
Resident Data
group by 	[PRIMARY ID];

LEFT join
 LOAD *
 Resident Data;
Drop Table Data;
Exit script&lt;/LI-CODE&gt;&lt;P&gt;It gives this output:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 563px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/29124iE6BD8B48ADD89A31/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2020 12:21:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/First-sorted-Value-for-min-and-max-date-for-each-ID/m-p/1679431#M727703</guid>
      <dc:creator>Vegar</dc:creator>
      <dc:date>2020-02-26T12:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: First sorted Value for min and max date for each ID</title>
      <link>https://community.qlik.com/t5/QlikView/First-sorted-Value-for-min-and-max-date-for-each-ID/m-p/1679808#M727706</link>
      <description>&lt;P&gt;left joins really do wonders thanks for the help&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2020 11:14:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/First-sorted-Value-for-min-and-max-date-for-each-ID/m-p/1679808#M727706</guid>
      <dc:creator>Nathan22</dc:creator>
      <dc:date>2020-02-27T11:14:16Z</dc:date>
    </item>
  </channel>
</rss>

