<?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 Record required from the data based on criteria in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/First-Record-required-from-the-data-based-on-criteria/m-p/2540514#M109204</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;this should do it, no matter if is text or number&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;TEST2:
LOAD
    AGENT_CODE,
    "DATE",
    AMOUNT
FROM [lib://DataFiles/TEST2.qvd]
(qvd);

lEFT JOIN(TEST)
//precedent load to filter the unwanted records
load *
where record_flag = 1;
LOAD 
	if(AGENT_CODE &amp;lt;&amp;gt; previous(AGENT_CODE),1,0) as record_flag,
    *
RESIDENT TEST2
order by AGENT_CODE, DATE;

DROP TABLE TEST2;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Load the QVD&lt;/P&gt;&lt;P&gt;2. load again by resident and use the order by statement (you cant sort when loading qvd)&lt;/P&gt;&lt;P&gt;3. drop the loaded table from QVD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;BR /&gt;best,&lt;/P&gt;</description>
    <pubDate>Thu, 08 Jan 2026 12:51:00 GMT</pubDate>
    <dc:creator>RafaelBarrios</dc:creator>
    <dc:date>2026-01-08T12:51:00Z</dc:date>
    <item>
      <title>First Record required from the data based on criteria</title>
      <link>https://community.qlik.com/t5/App-Development/First-Record-required-from-the-data-based-on-criteria/m-p/2540366#M109180</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I want to extract only 1 record from the data. In ABC data there are more than 1 records against these agent codes and i want to filter only 1 record from that. I have written below given code but i have not got any records.&lt;/P&gt;&lt;P&gt;Any help is appreciated.&lt;/P&gt;&lt;P&gt;TEST:&lt;/P&gt;&lt;P&gt;Load * Inline [&lt;BR /&gt;AGENT_CODE&lt;BR /&gt;12345678&lt;BR /&gt;23456789&lt;BR /&gt;34568901&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;Left Join&lt;BR /&gt;LOAD&lt;BR /&gt;POLICY_NO,&lt;BR /&gt;AREA_CODE,&lt;BR /&gt;APPLICATION_NO,&lt;BR /&gt;text(AGENT_CODE)&lt;BR /&gt;FROM [lib://SQL_BASE_EXTRACT_LAYER/LAYER_1/ABC.qvd]&lt;BR /&gt;(qvd) where Exists(AGENT_CODE);&lt;/P&gt;&lt;P&gt;NoConcatenate&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;FirstRecordPerAgent:&lt;BR /&gt;LOAD&lt;BR /&gt;AGENT_CODE,&lt;BR /&gt;FirstSortedValue(POLICY_NO, POLICY_NO) AS First_POLICY_NO,&lt;BR /&gt;FirstSortedValue(AREA_CODE, POLICY_NO) AS First_AREA_CODE,&lt;BR /&gt;FirstSortedValue(APPLICATION_NO, POLICY_NO) AS First_APPLICATION_NO&lt;BR /&gt;RESIDENT TEST&lt;BR /&gt;GROUP BY AGENT_CODE;&lt;BR /&gt;Drop Table TEST;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jan 2026 07:50:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/First-Record-required-from-the-data-based-on-criteria/m-p/2540366#M109180</guid>
      <dc:creator>P_Kale</dc:creator>
      <dc:date>2026-01-07T07:50:05Z</dc:date>
    </item>
    <item>
      <title>Re: First Record required from the data based on criteria</title>
      <link>https://community.qlik.com/t5/App-Development/First-Record-required-from-the-data-based-on-criteria/m-p/2540401#M109187</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/228839"&gt;@P_Kale&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;TEST:
Load * inline [
	AGENT_CODE
    12345678
    23456789
    34568901
];


lEFT JOIN(TEST)
//precedent load to filter the unwanted records
load *
where record_flag = 1;
//precedent load to flag the record we need
Load
	if(AGENT_CODE &amp;lt;&amp;gt; previous(AGENT_CODE),1,0) as record_flag, 
	*;
//LETS SAY THIS IS YOUR QVD
Load * inline [
     AGENT_CODE,DATE,AMOUNT
    12345678,2025-01-01,10
    12345678,2025-01-03,20
    12345678,2025-01-02,30
    23456789,2025-01-06,40
    23456789,2025-01-02,50
    23456789,2025-01-03,60
    23456789,2025-01-05,70
    34568901,2025-01-02,80
    34568901,2025-01-01,90
    34568901,2025-01-02,100
    34568901,2025-01-03,110
    34568901,2025-01-04,120
    34568901,2025-01-05,130
    34568901,2025-01-06,140
];&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;in my case, the "qvd" is sorted by AGENT_CODE, maybe you could need to first sort your Qvd and then do the flagging when AGENT_CODE change&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;TEST:
Load * inline [
	AGENT_CODE
    12345678
    23456789
    34568901
];

//LETS SAY THIS IS YOUR QVD
TEST2:
Load * inline [
     AGENT_CODE,DATE,AMOUNT
    12345678,2025-01-01,10
    12345678,2025-01-02,30
    34568901,2025-01-05,130
    23456789,2025-01-02,50
    34568901,2025-01-05,130
    12345678,2025-01-03,20
    23456789,2025-01-03,60
    23456789,2025-01-05,70
    34568901,2025-01-02,80
    34568901,2025-01-01,90
    34568901,2025-01-02,100
    34568901,2025-01-03,110
    23456789,2025-01-06,40
    34568901,2025-01-05,130
    34568901,2025-01-06,140
];

lEFT JOIN(TEST)
//precedent load to filter the unwanted records
load *
where record_flag = 1;
//precedent load to flag the record we need
LOAD 
	if(AGENT_CODE &amp;lt;&amp;gt; previous(AGENT_CODE),1,0) as record_flag,
    *
RESIDENT TEST2
order by AGENT_CODE, DATE;

DROP TABLE TEST2;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;BR /&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;help users find answers! Don't forget to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT color="#993366"&gt;mark a solution&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;that worked for you &amp;amp; to smash the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT color="#339966"&gt;like button&lt;/FONT&gt;!&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jan 2026 12:49:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/First-Record-required-from-the-data-based-on-criteria/m-p/2540401#M109187</guid>
      <dc:creator>RafaelBarrios</dc:creator>
      <dc:date>2026-01-07T12:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: First Record required from the data based on criteria</title>
      <link>https://community.qlik.com/t5/App-Development/First-Record-required-from-the-data-based-on-criteria/m-p/2540463#M109198</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/80977"&gt;@RafaelBarrios&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having AGENT_CODE is in text so how to do sorting.&lt;/P&gt;&lt;P&gt;Can you pl help&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2026 05:48:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/First-Record-required-from-the-data-based-on-criteria/m-p/2540463#M109198</guid>
      <dc:creator>P_Kale</dc:creator>
      <dc:date>2026-01-08T05:48:22Z</dc:date>
    </item>
    <item>
      <title>Re: First Record required from the data based on criteria</title>
      <link>https://community.qlik.com/t5/App-Development/First-Record-required-from-the-data-based-on-criteria/m-p/2540514#M109204</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;this should do it, no matter if is text or number&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;TEST2:
LOAD
    AGENT_CODE,
    "DATE",
    AMOUNT
FROM [lib://DataFiles/TEST2.qvd]
(qvd);

lEFT JOIN(TEST)
//precedent load to filter the unwanted records
load *
where record_flag = 1;
LOAD 
	if(AGENT_CODE &amp;lt;&amp;gt; previous(AGENT_CODE),1,0) as record_flag,
    *
RESIDENT TEST2
order by AGENT_CODE, DATE;

DROP TABLE TEST2;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Load the QVD&lt;/P&gt;&lt;P&gt;2. load again by resident and use the order by statement (you cant sort when loading qvd)&lt;/P&gt;&lt;P&gt;3. drop the loaded table from QVD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;BR /&gt;best,&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2026 12:51:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/First-Record-required-from-the-data-based-on-criteria/m-p/2540514#M109204</guid>
      <dc:creator>RafaelBarrios</dc:creator>
      <dc:date>2026-01-08T12:51:00Z</dc:date>
    </item>
    <item>
      <title>Re: First Record required from the data based on criteria</title>
      <link>https://community.qlik.com/t5/App-Development/First-Record-required-from-the-data-based-on-criteria/m-p/2540589#M109215</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/80977"&gt;@RafaelBarrios&lt;/a&gt;&amp;nbsp;Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jan 2026 11:10:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/First-Record-required-from-the-data-based-on-criteria/m-p/2540589#M109215</guid>
      <dc:creator>P_Kale</dc:creator>
      <dc:date>2026-01-09T11:10:14Z</dc:date>
    </item>
    <item>
      <title>Re: First Record required from the data based on criteria</title>
      <link>https://community.qlik.com/t5/App-Development/First-Record-required-from-the-data-based-on-criteria/m-p/2540594#M109218</link>
      <description>&lt;P&gt;anytime !!!&lt;/P&gt;&lt;P&gt;best regards,&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jan 2026 12:17:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/First-Record-required-from-the-data-based-on-criteria/m-p/2540594#M109218</guid>
      <dc:creator>RafaelBarrios</dc:creator>
      <dc:date>2026-01-09T12:17:49Z</dc:date>
    </item>
  </channel>
</rss>

