<?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: Identifying First and Last Value of each ID within Script in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Identifying-First-and-Last-Value-of-each-ID-within-Script/m-p/1656540#M593768</link>
    <description>&lt;P&gt;You can add another load where you sort descending on Date&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Testing:
LOAD * INLINE [
    Date, ID, Owed, Status, Movement
    31/12/2018,23, 0, , 0
    31/12/2018, 45, 10, , 0
    31/01/2019, 23, 0, , 0
    31/01/2019, 45, 10, , 0
    28/02/2019, 23, 0, , 0
    28/02/2019, 45, 10, , 0
    31/03/2019, 23, 10, New, 10
    31/03/2019, 45, 15, Increase, 5
    30/04/2019, 23, 10, , 0
    30/04/2019, 45, 10, Decrease, -5
    31/05/2019, 23, 15, Increase, 5
    31/05/2019, 45, 10, , 0
    30/06/2019, 23, 10, Decrease, -5
    30/06/2019, 45, 12, Increase, 2
    31/07/2019, 23, 10, , 0
    31/07/2019, 45, 10, Decrease, -2
    31/08/2019, 23, 15, Increase, 5
    31/08/2019, 45, 10, , 0
    30/09/2019, 23, 14, Decrease, -1
    30/09/2019, 45, 0, Paid off, -10
    31/10/2019, 23, 10, Decrease, -4
    31/10/2019, 45, 0, , 0
    30/11/2019, 23, 0, Paid off, -10
    30/11/2019, 45, 0, , 0
    31/12/2019, 23, 0, , 0
    31/12/2019, 45, 0, , 0
];

Sorted_Data_Temp1:
LOAD *,
	 if(ID = Peek(ID), Null(), 'Last') as "Origination_Temp1"
Resident Testing
Order by ID, Date desc;

Sorted_Data_Temp2:
LOAD *,
	 if(ID = Peek(ID), Null(), 'First') as "Origination_Temp2"
Resident Sorted_Data_Temp1
Order by ID, Date;

Sorted_Data:
LOAD Date,
	 ID,
	 Owed,
	 Status,
	 Movement,
	 If(Len(Trim(Origination_Temp2)) &amp;gt; 0, Origination_Temp2,
	 	If(Len(Trim(Origination_Temp1)) &amp;gt; 0, Origination_Temp1)) as "Origination"
Resident Sorted_Data_Temp2;

DROP Table Testing, Sorted_Data_Temp1, Sorted_Data_Temp2;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 11 Dec 2019 14:01:35 GMT</pubDate>
    <dc:creator>sunny_talwar</dc:creator>
    <dc:date>2019-12-11T14:01:35Z</dc:date>
    <item>
      <title>Identifying First and Last Value of each ID within Script</title>
      <link>https://community.qlik.com/t5/QlikView/Identifying-First-and-Last-Value-of-each-ID-within-Script/m-p/1656515#M593767</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;I have a table with a few columns.&amp;nbsp; What I need to do is to group and identify the first and the last record for each id.&amp;nbsp; I have managed to identify the first one, but getting the last one is proving to be complicated.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;Origination(Expected)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Jan&lt;/TD&gt;&lt;TD&gt;23&lt;/TD&gt;&lt;TD&gt;First&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Feb&lt;/TD&gt;&lt;TD&gt;23&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Mar&lt;/TD&gt;&lt;TD&gt;23&lt;/TD&gt;&lt;TD&gt;Last&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Jan&lt;/TD&gt;&lt;TD&gt;45&lt;/TD&gt;&lt;TD&gt;First&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Feb&lt;/TD&gt;&lt;TD&gt;45&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Mar&lt;/TD&gt;&lt;TD&gt;45&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Apr&lt;/TD&gt;&lt;TD&gt;45&lt;/TD&gt;&lt;TD&gt;Last&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And here is my code for the First:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Testing:
LOAD * INLINE [
    Date, ID, Owed, Status, Movement
    31/12/2018,23, 0, , 0
    31/12/2018, 45, 10, , 0
    31/01/2019, 23, 0, , 0
    31/01/2019, 45, 10, , 0
    28/02/2019, 23, 0, , 0
    28/02/2019, 45, 10, , 0
    31/03/2019, 23, 10, New, 10
    31/03/2019, 45, 15, Increase, 5
    30/04/2019, 23, 10, , 0
    30/04/2019, 45, 10, Decrease, -5
    31/05/2019, 23, 15, Increase, 5
    31/05/2019, 45, 10, , 0
    30/06/2019, 23, 10, Decrease, -5
    30/06/2019, 45, 12, Increase, 2
    31/07/2019, 23, 10, , 0
    31/07/2019, 45, 10, Decrease, -2
    31/08/2019, 23, 15, Increase, 5
    31/08/2019, 45, 10, , 0
    30/09/2019, 23, 14, Decrease, -1
    30/09/2019, 45, 0, Paid off, -10
    31/10/2019, 23, 10, Decrease, -4
    31/10/2019, 45, 0, , 0
    30/11/2019, 23, 0, Paid off, -10
    30/11/2019, 45, 0, , 0
    31/12/2019, 23, 0, , 0
    31/12/2019, 45, 0, , 0
];
NoConcatenate
Sorted_Data:
LOAD *,
if(ID = Peek(ID),'Old','New') as "Origination"
Resident Testing
Order by ID, Date;
DROP Table Testing;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just can not get the Last identified.&lt;/P&gt;&lt;P&gt;Any help is more than appreciated&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 01:43:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Identifying-First-and-Last-Value-of-each-ID-within-Script/m-p/1656515#M593767</guid>
      <dc:creator>aetingu12</dc:creator>
      <dc:date>2024-11-16T01:43:21Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying First and Last Value of each ID within Script</title>
      <link>https://community.qlik.com/t5/QlikView/Identifying-First-and-Last-Value-of-each-ID-within-Script/m-p/1656540#M593768</link>
      <description>&lt;P&gt;You can add another load where you sort descending on Date&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Testing:
LOAD * INLINE [
    Date, ID, Owed, Status, Movement
    31/12/2018,23, 0, , 0
    31/12/2018, 45, 10, , 0
    31/01/2019, 23, 0, , 0
    31/01/2019, 45, 10, , 0
    28/02/2019, 23, 0, , 0
    28/02/2019, 45, 10, , 0
    31/03/2019, 23, 10, New, 10
    31/03/2019, 45, 15, Increase, 5
    30/04/2019, 23, 10, , 0
    30/04/2019, 45, 10, Decrease, -5
    31/05/2019, 23, 15, Increase, 5
    31/05/2019, 45, 10, , 0
    30/06/2019, 23, 10, Decrease, -5
    30/06/2019, 45, 12, Increase, 2
    31/07/2019, 23, 10, , 0
    31/07/2019, 45, 10, Decrease, -2
    31/08/2019, 23, 15, Increase, 5
    31/08/2019, 45, 10, , 0
    30/09/2019, 23, 14, Decrease, -1
    30/09/2019, 45, 0, Paid off, -10
    31/10/2019, 23, 10, Decrease, -4
    31/10/2019, 45, 0, , 0
    30/11/2019, 23, 0, Paid off, -10
    30/11/2019, 45, 0, , 0
    31/12/2019, 23, 0, , 0
    31/12/2019, 45, 0, , 0
];

Sorted_Data_Temp1:
LOAD *,
	 if(ID = Peek(ID), Null(), 'Last') as "Origination_Temp1"
Resident Testing
Order by ID, Date desc;

Sorted_Data_Temp2:
LOAD *,
	 if(ID = Peek(ID), Null(), 'First') as "Origination_Temp2"
Resident Sorted_Data_Temp1
Order by ID, Date;

Sorted_Data:
LOAD Date,
	 ID,
	 Owed,
	 Status,
	 Movement,
	 If(Len(Trim(Origination_Temp2)) &amp;gt; 0, Origination_Temp2,
	 	If(Len(Trim(Origination_Temp1)) &amp;gt; 0, Origination_Temp1)) as "Origination"
Resident Sorted_Data_Temp2;

DROP Table Testing, Sorted_Data_Temp1, Sorted_Data_Temp2;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2019 14:01:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Identifying-First-and-Last-Value-of-each-ID-within-Script/m-p/1656540#M593768</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2019-12-11T14:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying First and Last Value of each ID within Script</title>
      <link>https://community.qlik.com/t5/QlikView/Identifying-First-and-Last-Value-of-each-ID-within-Script/m-p/1656559#M593769</link>
      <description>&lt;P&gt;Thank you very much as always!&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2019 14:23:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Identifying-First-and-Last-Value-of-each-ID-within-Script/m-p/1656559#M593769</guid>
      <dc:creator>aetingu12</dc:creator>
      <dc:date>2019-12-11T14:23:16Z</dc:date>
    </item>
  </channel>
</rss>

