<?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: Keep only the first record for a specific key in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Keep-only-the-first-record-for-a-specific-key/m-p/253869#M96174</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tried the following script and it loaded the first record only for each Key. If you replace the inline load to SQL SELECT statement to load from your SQL file and change the names of the key and data fields to the fieldnames in your SQL file, I think it should work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;Table1:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;LOAD * Where Key &amp;lt;&amp;gt; Previous(Key);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;LOAD * Inline [&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;Key, Data1, Data2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;1,A,B&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;1,C,CD&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;2,D,E&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;2,E,F&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;2,F,G&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;3,1,2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;3,2,3&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;3,3,4&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;];&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 04 Jul 2011 21:37:44 GMT</pubDate>
    <dc:creator>nagaiank</dc:creator>
    <dc:date>2011-07-04T21:37:44Z</dc:date>
    <item>
      <title>Keep only the first record for a specific key</title>
      <link>https://community.qlik.com/t5/QlikView/Keep-only-the-first-record-for-a-specific-key/m-p/253868#M96173</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to keep only the first record of an SQL file, when the key change&lt;/P&gt;&lt;P&gt;I use this script and it works fine. But i want to knows if i can do a better one (Try with "not exists" but don't seems to work)&lt;/P&gt;&lt;P&gt;Any suggestions&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thx&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline; color: #339966;"&gt;&lt;STRONG&gt;Works Ok :&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;TempArticles:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Text(CodeArticle) as [%ArticleID],&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Designation1 as [Désignation],&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Designation2 as [Désignation 2]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;SQL SELECT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CodeArticle,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Designation1,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Designation2&lt;/P&gt;&lt;P&gt;FROM ARTm;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// Tri de la table &amp;amp; Dédoublonage&lt;/P&gt;&lt;P&gt;TempArticles2:&lt;/P&gt;&lt;P&gt;NOCONCATENATE LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; *,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(%ArticleID=Previous(%ArticleID),null(),'1') as %1erEnr&lt;/P&gt;&lt;P&gt;RESIDENT [TempArticles] order by [%ArticleID];&lt;/P&gt;&lt;P&gt;DROP TABLE TempArticles;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Articles:&lt;/P&gt;&lt;P&gt;NOCONCATENATE LOAD * RESIDENT [TempArticles2] where %1erEnr;&lt;/P&gt;&lt;P&gt;DROP TABLE TempArticles2;&lt;/P&gt;&lt;P&gt;DROP FIELD %1erEnr;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline; color: #ff0000;"&gt;&lt;STRONG&gt;Don't works :&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Articles:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Text(CodeArticle) as [%ArticleID],&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Designation1 as [Désignation],&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Designation2 as [Désignation 2]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where not exists(%ArticleID,CodeArticle);&lt;/P&gt;&lt;P&gt;SQL SELECT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CodeArticle,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Designation1,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Designation2&lt;/P&gt;&lt;P&gt;FROM ARTm;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jul 2011 14:32:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Keep-only-the-first-record-for-a-specific-key/m-p/253868#M96173</guid>
      <dc:creator />
      <dc:date>2011-07-04T14:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: Keep only the first record for a specific key</title>
      <link>https://community.qlik.com/t5/QlikView/Keep-only-the-first-record-for-a-specific-key/m-p/253869#M96174</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tried the following script and it loaded the first record only for each Key. If you replace the inline load to SQL SELECT statement to load from your SQL file and change the names of the key and data fields to the fieldnames in your SQL file, I think it should work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;Table1:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;LOAD * Where Key &amp;lt;&amp;gt; Previous(Key);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;LOAD * Inline [&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;Key, Data1, Data2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;1,A,B&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;1,C,CD&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;2,D,E&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;2,E,F&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;2,F,G&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;3,1,2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;3,2,3&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;3,3,4&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;];&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jul 2011 21:37:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Keep-only-the-first-record-for-a-specific-key/m-p/253869#M96174</guid>
      <dc:creator>nagaiank</dc:creator>
      <dc:date>2011-07-04T21:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: Keep only the first record for a specific key</title>
      <link>https://community.qlik.com/t5/QlikView/Keep-only-the-first-record-for-a-specific-key/m-p/253870#M96175</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks. It is simpler. Here is my new code. I must use a resident table because my Articles Table is not sorted.&lt;/P&gt;&lt;P&gt;Do you know why the not exists clause don't works&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TempArticles:&lt;/P&gt;&lt;P&gt;LEFT KEEP (Lignes) LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Text(CodeArticle) as [%ArticleID],&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Designation1 as [Désignation],&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Designation2 as [Désignation 2]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;SQL SELECT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CodeArticle,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Designation1,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Designation2&lt;/P&gt;&lt;P&gt;FROM ARTm;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// Tri de la table &amp;amp; Dédoublonage&lt;/P&gt;&lt;P&gt;Articles:&lt;/P&gt;&lt;P&gt;NOCONCATENATE LOAD * RESIDENT [TempArticles] where %ArticleID&amp;lt;&amp;gt;Previous(%ArticleID) order by [%ArticleID];&lt;/P&gt;&lt;P&gt;DROP TABLE TempArticles;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jul 2011 08:17:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Keep-only-the-first-record-for-a-specific-key/m-p/253870#M96175</guid>
      <dc:creator />
      <dc:date>2011-07-05T08:17:38Z</dc:date>
    </item>
  </channel>
</rss>

