<?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: Choose top N values by groups in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231388#M856454</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to get 3 last purchases for each ID&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 Feb 2017 13:08:13 GMT</pubDate>
    <dc:creator />
    <dc:date>2017-02-08T13:08:13Z</dc:date>
    <item>
      <title>Choose top N values by groups</title>
      <link>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231382#M856442</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;Hi, everyone. May be anyone know how to get table with top N values by groups during load data?&lt;/SPAN&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/Choose-top-N-values-by-groups/m-p/1231382#M856442</guid>
      <dc:creator />
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Choose top N values by groups</title>
      <link>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231383#M856443</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe something like this for N=10:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Top10:&lt;/P&gt;&lt;P&gt;LOAD *&lt;/P&gt;&lt;P&gt;WHERE Rank &amp;lt;= 10;&lt;/P&gt;&lt;P&gt;LOAD Group, Value, Autonumber(recno(), Group) as Rank&lt;/P&gt;&lt;P&gt;RESIDENT YourTable&lt;/P&gt;&lt;P&gt;ORDER BY Group, Value desc;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2017 19:57:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231383#M856443</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2017-02-07T19:57:09Z</dc:date>
    </item>
    <item>
      <title>Re: Choose top N values by groups</title>
      <link>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231384#M856444</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks. I don't know why, but I get some values twice, because Rank was calculated wrong. May be the reason is that I by another column.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Feb 2017 10:37:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231384#M856444</guid>
      <dc:creator />
      <dc:date>2017-02-08T10:37:34Z</dc:date>
    </item>
    <item>
      <title>Re: Choose top N values by groups</title>
      <link>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231385#M856447</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;
&lt;P&gt;Vladimir Shatalov wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Thanks. I don't know why, but I get some values twice, because Rank was calculated wrong. May be the reason is that I by another column.&lt;/P&gt;
&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;You do what exactely by another column? I think there is a piece of information missing in your reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you post your script? And maybe some lines of sample data?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Feb 2017 12:06:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231385#M856447</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2017-02-08T12:06:42Z</dc:date>
    </item>
    <item>
      <title>Re: Choose top N values by groups</title>
      <link>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231386#M856449</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I havr columns with ID, date and purchase value. &lt;/P&gt;&lt;P&gt;My script &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table1:&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;Id,&lt;/P&gt;&lt;P&gt;Date,&lt;/P&gt;&lt;P&gt;Profit,&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 37.1059px;"&gt;purchase value&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 37.1059px;"&gt;From&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 37.1059px;"&gt;&lt;D&gt; (qvd)&lt;/D&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 37.1059px;"&gt;Where not isNull(profit)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 37.1059px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 37.1059px;"&gt;Top3:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 42.3924px;"&gt;// Load *&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 42.3924px;"&gt;// Where Rank&amp;lt;=3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 42.3924px;"&gt;Load&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 42.3924px;"&gt;ID,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 42.3924px;"&gt;Date as newdate,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 42.3924px;"&gt;Purchase value as newpurchase,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 42.3924px;"&gt;AutoNumber (RecNo(),ID) as Rank&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 42.3924px;"&gt;Resident Table1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 42.3924px;"&gt;Order by ID, Date desc;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 42.3924px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 42.3924px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 45.0356px;"&gt;I comment the part of code to test.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 47.3484px;"&gt;When I looked at the table content, I noticed that all the records in which the rank is less than three and&amp;nbsp; except the first ID &lt;SPAN style="font-size: 47.5136px;"&gt;duplicated&lt;/SPAN&gt;, but if I only upload table without autonumber, the records are not duplicated&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 45.0356px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Feb 2017 12:37:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231386#M856449</guid>
      <dc:creator />
      <dc:date>2017-02-08T12:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: Choose top N values by groups</title>
      <link>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231387#M856452</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure I understand.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've noticed that you ordered your second table by &lt;STRONG&gt;ID, Date desc&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So you are essentially ranking the dates per ID, not the purchases. Is this what you want?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Feb 2017 12:57:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231387#M856452</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2017-02-08T12:57:40Z</dc:date>
    </item>
    <item>
      <title>Re: Choose top N values by groups</title>
      <link>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231388#M856454</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to get 3 last purchases for each ID&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Feb 2017 13:08:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231388#M856454</guid>
      <dc:creator />
      <dc:date>2017-02-08T13:08:13Z</dc:date>
    </item>
    <item>
      <title>Re: Choose top N values by groups</title>
      <link>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231389#M856455</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you have multiple purchases for any given ID on a same date?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This approach will just order the purchases by date descending and should rank them in order, but it should assign a unique rank per line (unique per ID group). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you say that you are getting duplicate values, I can't see how this should duplicate anything. Maybe it's because your tables are still linked to other tables and the duplication occurs due to the QV logic?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If possible, post a small sample QVW or at least some input data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Feb 2017 16:15:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231389#M856455</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2017-02-08T16:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: Choose top N values by groups</title>
      <link>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231390#M856456</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;
&lt;P style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background-color: #f2f2f2;"&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12px; background-color: #f2f2f2;"&gt;Do you have multiple purchases for any given ID on a same dat?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P style="font-size: 12px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d; background-color: #f2f2f2;"&gt;&lt;SPAN style="background-color: transparent; color: #575757; font-family: arial, helvetica, sans-serif; font-size: 10pt;"&gt;I hope, that no, because i have date accurate to seconds.&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12px; background-color: #f2f2f2;"&gt;Maybe it's because your tables are still linked to other tables and the duplication occurs due to the QV logic?&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12px; background-color: #f2f2f2;"&gt;&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: 12px; background-color: #f2f2f2;"&gt;Yes, I Load two tables. They linked by ID&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: 12px; background-color: #f2f2f2;"&gt;&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: 12px; background-color: #f2f2f2;"&gt;My data looks like this &lt;A href="https://drive.google.com/file/d/0B1D9cwJJCyZ2c3ZNdU82ek5Pdzg/view?usp=sharing"&gt;https://drive.google.com/file/d/0B1D9cwJJCyZ2c3ZNdU82ek5Pdzg/view?usp=sharing&lt;/A&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Feb 2017 16:44:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231390#M856456</guid>
      <dc:creator />
      <dc:date>2017-02-08T16:44:12Z</dc:date>
    </item>
    <item>
      <title>Re: Choose top N values by groups</title>
      <link>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231391#M856457</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, and what is returned by your script using this data for rank?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Feb 2017 16:50:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231391#M856457</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2017-02-08T16:50:00Z</dc:date>
    </item>
    <item>
      <title>Re: Choose top N values by groups</title>
      <link>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231392#M856458</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;return this&lt;/P&gt;&lt;P&gt;&lt;A href="https://drive.google.com/file/d/0B1D9cwJJCyZ2QVk0Q3JFbV9qRk0/view?usp=sharing"&gt;https://drive.google.com/file/d/0B1D9cwJJCyZ2QVk0Q3JFbV9qRk0/view?usp=sharing&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Feb 2017 17:02:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231392#M856458</guid>
      <dc:creator />
      <dc:date>2017-02-08T17:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: Choose top N values by groups</title>
      <link>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231393#M856459</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you using a table box to view your data?&lt;/P&gt;&lt;P&gt;The table box will only show distinct combinations of field values, so it will not show any duplicates.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since the rank will create a new field, this might add the "distinctness" to your records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please check your source data, I assume that your source data already shows the duplicates (e.g. add a Rowno() in your script or a Count(ID) as expression in a straight table)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Other than that, your records don't seem to be sorted correctly when ranked, right?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Again, if possible, post some sample data that can be imported into QV.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Feb 2017 17:23:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231393#M856459</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2017-02-08T17:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: Choose top N values by groups</title>
      <link>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231394#M856460</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I used count. If I load data without autonumber - all is ok, but if I use it, some fields dulicates.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The sorting is correct. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately, I have no way to send real data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Feb 2017 17:36:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231394#M856460</guid>
      <dc:creator />
      <dc:date>2017-02-08T17:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: Choose top N values by groups</title>
      <link>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231395#M856461</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure what you mean with that.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/docs/DOC-16454"&gt;Uploading a Sample&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I asked for some real data to look at, for example the data you are already showing in your linked images, but we need to look at the source data that and your script.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Feb 2017 20:23:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231395#M856461</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2017-02-08T20:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: Choose top N values by groups</title>
      <link>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231396#M856462</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are rigth. The reason was in the data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2017 18:35:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Choose-top-N-values-by-groups/m-p/1231396#M856462</guid>
      <dc:creator />
      <dc:date>2017-02-09T18:35:56Z</dc:date>
    </item>
  </channel>
</rss>

