<?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: Aggr and rank not sorting in Text box in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Aggr-and-rank-not-sorting-in-Text-box/m-p/447647#M167059</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Found another similar option is to use negative in front of sort aggr, not sure if makes any difference or not, still have the above two questions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=CONCAT(DISTINCT IF(AGGR(Rank(SUM(INVOICE.Total)),CUSTOMER.LastName)&amp;lt;=3, CUSTOMER.LastName),' '&amp;amp;chr(13), -aggr(SUM(INVOICE.Total),CUSTOMER.LastName))&amp;nbsp; // WORKS, AND SORTS, BUT ASC, NEEDED TO ADD - TO GET IT TO SORT DESC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 17 Mar 2013 17:17:48 GMT</pubDate>
    <dc:creator />
    <dc:date>2013-03-17T17:17:48Z</dc:date>
    <item>
      <title>Aggr and rank not sorting in Text box</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-and-rank-not-sorting-in-Text-box/m-p/447644#M167056</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Read an article by Adam Bellerby on use of aggr.&amp;nbsp; Article was good. Link to article is below. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="html" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13634797108847087" jivemacro_uid="_13634797108847087"&gt;&lt;P&gt;&lt;A _jive_internal="true" class="loading" href="https://community.qlik.com/blogs/qlikviewdesignblog/2013/03/07/aggr" title="http://community.qlik.com/blogs/qlikviewdesignblog/2013/03/07/aggr"&gt;http://community.qlik.com/blogs/qlikviewdesignblog/2013/03/07/aggr&lt;/A&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Used the article in the attached .qvw.&amp;nbsp; It seems that the sort of the data in the rank is alpha and not by the top sales or in this case invoice.&amp;nbsp; This is the section in the document called:&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: gray;"&gt;AGGR &amp;amp; Rank()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Am I doing something wrong, or does the article just get lucky that the top salesperson is listed first?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found a way to sort the top three, but took two statement, can the existing concat/aggr/rank be changed to provide a sorted list in the text box by highest producer versus alphabetic which it seems?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Look at the textbox in the document. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know if you have any thoughts..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;D&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 17 Mar 2013 00:28:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-and-rank-not-sorting-in-Text-box/m-p/447644#M167056</guid>
      <dc:creator />
      <dc:date>2013-03-17T00:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr and rank not sorting in Text box</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-and-rank-not-sorting-in-Text-box/m-p/447645#M167057</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try using concat() with a sort weight (standard is sorting alphanumerical):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=CONCAT(DISTINCT IF(AGGR(Rank(SUM(INVOICE.Total)),CUSTOMER.LastName)&amp;lt;=3, CUSTOMER.LastName),',',&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; aggr(sum(INVOICE.Total),CUSTOMER.LastName)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;) &lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 17 Mar 2013 10:43:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-and-rank-not-sorting-in-Text-box/m-p/447645#M167057</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2013-03-17T10:43:02Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr and rank not sorting in Text box</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-and-rank-not-sorting-in-Text-box/m-p/447646#M167058</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Stefan, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help.... I do not have a license anymore so do not believe I can read your document.&amp;nbsp; The suggestion you made is correct, sweet.&amp;nbsp; To get it to sort DESC, i added a piece to the sorting aggr as *-1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Q1.&amp;nbsp; Is this the best way or is there another way?:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=CONCAT(DISTINCT IF(AGGR(Rank(SUM(INVOICE.Total)),CUSTOMER.LastName)&amp;lt;=3, CUSTOMER.LastName),',', aggr(SUM(INVOICE.Total),CUSTOMER.LastName)*-1)&amp;nbsp; // WORKS, AND SORTS, BUT ASC, NEEDED TO ADD *-1 TO GET IT TO SORT DESC&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note, I stupidly used a nonaggr function to sort which did not work, should of stayed consistent.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Q2.&amp;nbsp; Why does the following not work?&amp;nbsp; Is it because there is no dimension on the text box or something in my syntax?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=CONCAT(DISTINCT IF(AGGR(Rank(SUM(INVOICE.Total)),CUSTOMER.LastName)&amp;lt;=3, CUSTOMER.LastName),'|', SUM(TOTAL INVOICE.Total &amp;lt;CUSTOMER.LastName&amp;gt;))&amp;nbsp; // WORKS, but sort still off, probably cause no dimension in text box???&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;D&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 17 Mar 2013 16:17:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-and-rank-not-sorting-in-Text-box/m-p/447646#M167058</guid>
      <dc:creator />
      <dc:date>2013-03-17T16:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr and rank not sorting in Text box</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-and-rank-not-sorting-in-Text-box/m-p/447647#M167059</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Found another similar option is to use negative in front of sort aggr, not sure if makes any difference or not, still have the above two questions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=CONCAT(DISTINCT IF(AGGR(Rank(SUM(INVOICE.Total)),CUSTOMER.LastName)&amp;lt;=3, CUSTOMER.LastName),' '&amp;amp;chr(13), -aggr(SUM(INVOICE.Total),CUSTOMER.LastName))&amp;nbsp; // WORKS, AND SORTS, BUT ASC, NEEDED TO ADD - TO GET IT TO SORT DESC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 17 Mar 2013 17:17:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-and-rank-not-sorting-in-Text-box/m-p/447647#M167059</guid>
      <dc:creator />
      <dc:date>2013-03-17T17:17:48Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr and rank not sorting in Text box</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-and-rank-not-sorting-in-Text-box/m-p/447648#M167060</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Using a multiplication *-1 or a preceding minus sign should equivalent, right?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And you are right, you need to use the negative sums when sorting desc, I missed that in my post.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Q1: I am not sure if there is more simple solution, at least I can't think of one right now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Q2: I think your sort weight expression is not correct syntax:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SUM(TOTAL INVOICE.Total &amp;lt;CUSTOMER.LastName&amp;gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what should this mean? you can use a field list after your field named INVOICE.Total&lt;/P&gt;&lt;P&gt;Have you intended to use the field list after the first total? I think it's not allowed to use this aggregation inside the outer aggregation (concat() function). That's why you need to use the advanced aggregation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you can precalculate the sums, this would make your expression somewhat less complex, of course...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 17 Mar 2013 19:40:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-and-rank-not-sorting-in-Text-box/m-p/447648#M167060</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2013-03-17T19:40:48Z</dc:date>
    </item>
  </channel>
</rss>

