<?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: Get Top 2 Records from a Table based on Group by in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Get-Top-N-Records-from-a-Table-based-on-Group-by/m-p/1449733#M816461</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;temp:&lt;/P&gt;&lt;P&gt;Load * Inline [&lt;/P&gt;&lt;P&gt;Category, Value&lt;/P&gt;&lt;P&gt;A, 1&lt;/P&gt;&lt;P&gt;A, 9&lt;/P&gt;&lt;P&gt;A, 2&lt;/P&gt;&lt;P&gt;A, 4&lt;/P&gt;&lt;P&gt;A, 7&lt;/P&gt;&lt;P&gt;B, 11&lt;/P&gt;&lt;P&gt;B, 15&lt;/P&gt;&lt;P&gt;B, 10&lt;/P&gt;&lt;P&gt;B, 14&lt;/P&gt;&lt;P&gt;];&lt;/P&gt;&lt;P&gt;NoConcatenate&lt;/P&gt;&lt;P&gt;Final:&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;&amp;nbsp; *,&lt;/P&gt;&lt;P&gt;&amp;nbsp; AutoNumber(Value, Category)&lt;/P&gt;&lt;P&gt;Resident temp &lt;STRONG&gt;Where AutoNumber(Value, Category)&amp;lt;3 Order By Category, Value desc;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;DROP Table temp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;IMG alt="Capture.PNG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/175790_Capture.PNG" style="height: auto;" /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 07 Sep 2017 08:26:01 GMT</pubDate>
    <dc:creator>tresB</dc:creator>
    <dc:date>2017-09-07T08:26:01Z</dc:date>
    <item>
      <title>Get Top N Records from a Table based on Group by</title>
      <link>https://community.qlik.com/t5/QlikView/Get-Top-N-Records-from-a-Table-based-on-Group-by/m-p/1449731#M816459</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to get the Top 2 Records from a Field for each Category.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Say the following is my Input data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="175774" alt="Top 2 - Reference Screenshot 2.PNG" class="jive-image image-1" src="/legacyfs/online/175774_Top 2 - Reference Screenshot 2.PNG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;And I need to get the Top 2 (Maximum) from each Category, which is A should have 8 and 5 while B should have 9 and 8.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How should I use the Max() function in the Load Script? From what I have searched, I found that Max(Value, 2) should give the solution. But it is not working. I am getting the following output instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="175787" alt="Top 2 - Reference Screenshot.PNG" class="jive-image image-2" src="/legacyfs/online/175787_Top 2 - Reference Screenshot.PNG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;What is the best way to achieve this is in &lt;STRONG&gt;LOAD SCRIPT?&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Get-Top-N-Records-from-a-Table-based-on-Group-by/m-p/1449731#M816459</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Get Top 2 Records from a Table based on Group by</title>
      <link>https://community.qlik.com/t5/QlikView/Get-Top-N-Records-from-a-Table-based-on-Group-by/m-p/1449732#M816460</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;FIRSTSORTEDVALUE() should help here,&lt;/P&gt;&lt;P&gt;aircode might be&lt;/P&gt;&lt;P&gt;TopRanks:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;Category,&lt;/P&gt;&lt;P&gt;FIRSTSORTEDVALUE(Category, Value, 1)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AS TopValue&lt;/P&gt;&lt;P&gt;RESIDENT&lt;/P&gt;&lt;P&gt;MyTable&lt;/P&gt;&lt;P&gt;GROUP BY&lt;/P&gt;&lt;P&gt;Category;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CONCATENATE (TopRanks) LOAD&lt;/P&gt;&lt;P&gt;Category,&lt;/P&gt;&lt;P&gt;FIRSTSORTEDVALUE(Category, Value, 2)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AS TopValue&lt;/P&gt;&lt;P&gt;RESIDENT&lt;/P&gt;&lt;P&gt;MyTable&lt;/P&gt;&lt;P&gt;GROUP BY&lt;/P&gt;&lt;P&gt;Category;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Sep 2017 08:22:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Get-Top-N-Records-from-a-Table-based-on-Group-by/m-p/1449732#M816460</guid>
      <dc:creator>prieper</dc:creator>
      <dc:date>2017-09-07T08:22:00Z</dc:date>
    </item>
    <item>
      <title>Re: Get Top 2 Records from a Table based on Group by</title>
      <link>https://community.qlik.com/t5/QlikView/Get-Top-N-Records-from-a-Table-based-on-Group-by/m-p/1449733#M816461</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;temp:&lt;/P&gt;&lt;P&gt;Load * Inline [&lt;/P&gt;&lt;P&gt;Category, Value&lt;/P&gt;&lt;P&gt;A, 1&lt;/P&gt;&lt;P&gt;A, 9&lt;/P&gt;&lt;P&gt;A, 2&lt;/P&gt;&lt;P&gt;A, 4&lt;/P&gt;&lt;P&gt;A, 7&lt;/P&gt;&lt;P&gt;B, 11&lt;/P&gt;&lt;P&gt;B, 15&lt;/P&gt;&lt;P&gt;B, 10&lt;/P&gt;&lt;P&gt;B, 14&lt;/P&gt;&lt;P&gt;];&lt;/P&gt;&lt;P&gt;NoConcatenate&lt;/P&gt;&lt;P&gt;Final:&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;&amp;nbsp; *,&lt;/P&gt;&lt;P&gt;&amp;nbsp; AutoNumber(Value, Category)&lt;/P&gt;&lt;P&gt;Resident temp &lt;STRONG&gt;Where AutoNumber(Value, Category)&amp;lt;3 Order By Category, Value desc;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;DROP Table temp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;IMG alt="Capture.PNG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/175790_Capture.PNG" style="height: auto;" /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Sep 2017 08:26:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Get-Top-N-Records-from-a-Table-based-on-Group-by/m-p/1449733#M816461</guid>
      <dc:creator>tresB</dc:creator>
      <dc:date>2017-09-07T08:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: Get Top 2 Records from a Table based on Group by</title>
      <link>https://community.qlik.com/t5/QlikView/Get-Top-N-Records-from-a-Table-based-on-Group-by/m-p/1449734#M816462</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can try this as well with MAX() functions&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM&gt;TempTab:&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM&gt;Load &lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM&gt;Category,&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM&gt;Value&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM&gt;From Source;&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM&gt;MainTab:&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM&gt;LOAD&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM&gt;Category,&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM&gt;Max(Value)&amp;nbsp; AS MaxValue&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM&gt;RESIDENT &lt;/EM&gt;&lt;EM&gt;TempTab&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM&gt;GROUP BY &lt;/EM&gt;&lt;EM&gt;Category;&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM&gt;Concatenate(&lt;EM style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;MainTab&lt;/EM&gt;)&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM&gt;LOAD&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM&gt;Category,&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM&gt;Max(Value,2)&amp;nbsp; AS MaxValue&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM&gt;RESIDENT &lt;/EM&gt;&lt;EM style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;TempTab&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM&gt;GROUP BY Category;&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM&gt;Drop Table &lt;EM style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;TempTab;&lt;/EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Sep 2017 08:31:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Get-Top-N-Records-from-a-Table-based-on-Group-by/m-p/1449734#M816462</guid>
      <dc:creator>its_anandrjs</dc:creator>
      <dc:date>2017-09-07T08:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: Get Top 2 Records from a Table based on Group by</title>
      <link>https://community.qlik.com/t5/QlikView/Get-Top-N-Records-from-a-Table-based-on-Group-by/m-p/1449735#M816463</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So if it is top N, you have to just change here:&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Where AutoNumber(Value, Category)&amp;lt;&lt;SPAN style="color: #ff0000;"&gt;=N&lt;/SPAN&gt; Order By Category, Value desc;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Sep 2017 08:54:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Get-Top-N-Records-from-a-Table-based-on-Group-by/m-p/1449735#M816463</guid>
      <dc:creator>tresB</dc:creator>
      <dc:date>2017-09-07T08:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: Get Top N Records from a Table based on Group by</title>
      <link>https://community.qlik.com/t5/QlikView/Get-Top-N-Records-from-a-Table-based-on-Group-by/m-p/1449736#M816464</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot, Anand. Understood that there is no single straight way to achieve the output. &lt;A href="https://community.qlik.com/qlik-users/26418"&gt;tresesco&lt;/A&gt;‌ Solution worked in one Go. Still not sure about the Running Time when used with bigger Larger Data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Sep 2017 09:00:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Get-Top-N-Records-from-a-Table-based-on-Group-by/m-p/1449736#M816464</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-09-07T09:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: Get Top N Records from a Table based on Group by</title>
      <link>https://community.qlik.com/t5/QlikView/Get-Top-N-Records-from-a-Table-based-on-Group-by/m-p/1449737#M816465</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Koushik,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's better to avoid group by in the load script as it will consume more time while loading the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try to do it in the visual layer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=If(Rank(Sum(Distinct(Value)))&amp;lt;=2,Value,null())&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many Thanks&lt;/P&gt;&lt;P&gt;Karthik&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Sep 2017 09:02:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Get-Top-N-Records-from-a-Table-based-on-Group-by/m-p/1449737#M816465</guid>
      <dc:creator>karthikoffi27se</dc:creator>
      <dc:date>2017-09-07T09:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: Get Top N Records from a Table based on Group by</title>
      <link>https://community.qlik.com/t5/QlikView/Get-Top-N-Records-from-a-Table-based-on-Group-by/m-p/1449738#M816466</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Koushik, Thanks for the information but if you are working on the Load Script and using JOINs for some tables is good because JOINs take less lime to process in comparison to Mappings Or Group By Or Order By they take time to arrange the table with its all fields and grouped the data for those fields. It is preferred if you have large table go for the Joins rather than Group By but it is still the trick to do the modelling on the tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps you.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Sep 2017 09:10:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Get-Top-N-Records-from-a-Table-based-on-Group-by/m-p/1449738#M816466</guid>
      <dc:creator>its_anandrjs</dc:creator>
      <dc:date>2017-09-07T09:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: Get Top N Records from a Table based on Group by</title>
      <link>https://community.qlik.com/t5/QlikView/Get-Top-N-Records-from-a-Table-based-on-Group-by/m-p/1449739#M816467</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Also please check is this your Out put from the table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Out put that you preferred. &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;A should have 8 and 5 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;B should have 9 and 8.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Sep 2017 09:13:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Get-Top-N-Records-from-a-Table-based-on-Group-by/m-p/1449739#M816467</guid>
      <dc:creator>its_anandrjs</dc:creator>
      <dc:date>2017-09-07T09:13:35Z</dc:date>
    </item>
  </channel>
</rss>

