<?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: Aggregate, max and sum in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Aggregate-max-and-sum/m-p/1162988#M463708</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you by your answer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your expression gives me the max (work) --&amp;gt; 587. Not the max (work) which % = 100 &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/sad.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 09 Jun 2016 15:06:05 GMT</pubDate>
    <dc:creator>vdcastro</dc:creator>
    <dc:date>2016-06-09T15:06:05Z</dc:date>
    <item>
      <title>Aggregate, max and sum</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregate-max-and-sum/m-p/1162985#M463705</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am having some problems in an set analysis operation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have this table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="149" style="border: 1px solid rgb(0, 0, 0); width: 281px; height: 61px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align:center;background-color:#6690BC;color:#ffffff;padding:2px;" valign="middle"&gt;&lt;STRONG&gt;ID-Person&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align:center;background-color:#6690BC;color:#ffffff;padding:2px;" valign="middle"&gt;Work&lt;/TH&gt;&lt;TH style="text-align:center;background-color:#6690BC;color:#ffffff;padding:2px;" valign="middle"&gt;&lt;STRONG&gt;Goal&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;576&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;212&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;224&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;605&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;215&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;217&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;587&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;&lt;SPAN style="font-size: 13.3333px; text-align: center;"&gt;3838&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;3854&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;549&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;11&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;11&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;572&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;271&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;271&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i want to find the max (%) of work/goal of all persons but including the max work. For this table i want the max(work/goal) and the result can be:&lt;/P&gt;&lt;P&gt; id_person 549 or 572. But as i want too the max(work) the result should be 572.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I made this expression:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=FirstSortedValue(Distinct id_person,-aggr(sum({$&amp;lt;type={'work'}&amp;gt;}#Count)/sum({$&amp;lt;objective={'goal'}&amp;gt;}#Count),id_person)) and the result is 549 (the first possibility that appears) and i want 572 because the field "work" is bigger.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone help me?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greetings&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Vítor&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jun 2016 13:35:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregate-max-and-sum/m-p/1162985#M463705</guid>
      <dc:creator>vdcastro</dc:creator>
      <dc:date>2016-06-09T13:35:25Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate, max and sum</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregate-max-and-sum/m-p/1162986#M463706</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try something like &lt;/P&gt;&lt;P&gt;&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;=FirstSortedValue(Distinct&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;id_person,&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;-aggr(sum({$&amp;lt;type={'work'}&amp;gt;}#Count)/sum({$&amp;lt;objective={'goal'}&amp;gt;}#Count)&lt;STRONG&gt;+&lt;/STRONG&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;STRONG&gt;sum({$&amp;lt;type={'work'}&amp;gt;}#Count)/pow(10,9)&lt;/STRONG&gt;&lt;/SPAN&gt;,&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;id_person)&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;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;i.e. add a small number proportional to work load to break the ties.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jun 2016 13:44:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregate-max-and-sum/m-p/1162986#M463706</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2016-06-09T13:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate, max and sum</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregate-max-and-sum/m-p/1162987#M463707</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this:&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;&lt;STRONG&gt;=FirstSortedValue(DISTINCT id_person,-Aggr(&lt;/STRONG&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;&lt;STRONG&gt;(Sum({$&amp;lt;type={'work'}&amp;gt;}#Count)/Sum({$&amp;lt;objective={'goal'}&amp;gt;}#Count) * 100000) + &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Sum({$&amp;lt;type={'work'}&amp;gt;}#Count) &lt;/SPAN&gt;,id_person))&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jun 2016 13:48:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregate-max-and-sum/m-p/1162987#M463707</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2016-06-09T13:48:23Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate, max and sum</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregate-max-and-sum/m-p/1162988#M463708</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you by your answer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your expression gives me the max (work) --&amp;gt; 587. Not the max (work) which % = 100 &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/sad.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jun 2016 15:06:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregate-max-and-sum/m-p/1162988#M463708</guid>
      <dc:creator>vdcastro</dc:creator>
      <dc:date>2016-06-09T15:06:05Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate, max and sum</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregate-max-and-sum/m-p/1162989#M463709</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It works &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you very much by your help &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jun 2016 15:08:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregate-max-and-sum/m-p/1162989#M463709</guid>
      <dc:creator>vdcastro</dc:creator>
      <dc:date>2016-06-09T15:08:18Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate, max and sum</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregate-max-and-sum/m-p/1162990#M463710</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If my response is not the correct response, please mark Stefan's response as the correct answer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Sunny&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jun 2016 15:17:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregate-max-and-sum/m-p/1162990#M463710</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2016-06-09T15:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate, max and sum</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregate-max-and-sum/m-p/1162991#M463711</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would like to understand better your answer...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;why did you sum?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;why the pow?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if we need the opposite effect, do we just need to do something like (minimum goal/work with minimum work):&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;=FirstSortedValue(Distinct&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;id_person,&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;aggr(sum({$&amp;lt;type={'work'}&amp;gt;}#Count)/sum({$&amp;lt;objective={'goal'}&amp;gt;}#Count)-&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;sum({$&amp;lt;type={'work'}&amp;gt;}#Count)/pow(10,9)&lt;/STRONG&gt;&lt;/SPAN&gt;,&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;id_person)&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;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;just to learn a little bit &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&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;thank you very much&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 10:37:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregate-max-and-sum/m-p/1162991#M463711</guid>
      <dc:creator>vdcastro</dc:creator>
      <dc:date>2016-06-15T10:37:51Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate, max and sum</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregate-max-and-sum/m-p/1162992#M463712</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi swuhel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Very shrewd approach , just wanted to check the reason of using pow(10,9) as pow(10,4) and onwards should serve the purpose.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 12:19:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregate-max-and-sum/m-p/1162992#M463712</guid>
      <dc:creator />
      <dc:date>2016-06-15T12:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate, max and sum</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregate-max-and-sum/m-p/1162993#M463713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The syntax for FirstSortedValue() is&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Bold"&gt;firstsortedvalue(&lt;/SPAN&gt;&lt;SPAN class="Italic"&gt;[{set_expression}][ &lt;SPAN class="Bold"&gt;distinct&lt;/SPAN&gt; ] [ &lt;SPAN class="Bold"&gt;total&lt;/SPAN&gt; [&amp;lt;fld {, fld}&amp;gt;]] expression [, sort_weight [, n]]&lt;/SPAN&gt;&lt;SPAN class="Bold"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Bold"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Bold"&gt;You want to create a list of persons, and your sort weight should be Work/Goal per person, hence your original expression:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Bold"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;=FirstSortedValue(Distinct &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id_person&lt;/EM&gt;&lt;/STRONG&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;&lt;EM&gt;&amp;nbsp; -aggr(sum({$&amp;lt;type={'work'}&amp;gt;}#Count)/sum({$&amp;lt;objective={'goal'}&amp;gt;}#Count),id_person)&lt;/EM&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(To create the sort weight per person, use advanced aggregation with dimension id_person and the aggregated Work divided by aggregated goal as expression. You only need to sum work / goal if there might be several records per person id for work and goal. Essentially, this is your original expression.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The issue with FirstSortedValue() is that it returns NULL if there are two or more lines in the sort weight temporary table with the same highest sort order. You can use DISTINCT to overcome this and return the first line's value in LOAD order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But your requirement is different: If there are ties, consider the one with the higher work amount.&lt;/P&gt;&lt;P&gt;So the rule is: sort by work / goal, get the lines with the highest quotient and of there are more than one, the one with the highest work amount.&lt;/P&gt;&lt;P&gt;(Note that I am talking about highest values here, which we achieve by using an additional minus before the aggr(), because FirstSortedValue() basically looks for the lowest value)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can do this by adding a small number to the original sort weight,proportional to work amount, &lt;STRONG&gt;&lt;EM&gt;but this number needs to be much smaller than the typical sort weight value, it just should play a role when there are equal original sort weight values, to break the tie.&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note also that it doesn't make a big difference if you adding the work divided by a large number, to create the small tie-breaker proportional to work load (my version) or if you multiplying the original sort weight by a large number, then just add the work load (Sunny's version).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;It's only important that the factor is large enough to not change the original sort order per person_id, it should only break ties. &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;My number was large enough, Sunny's number wasn't for your data. But the factor you need to chose may depend on your data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It then doesn't matter if you write pow(10,9) or 1000000000.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you want to find minimum work/goal with minimum work, you need to first remove the minus before the aggr() function&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;=FirstSortedValue(Distinct&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;id_person,&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;aggr(sum({$&amp;lt;type={'work'}&amp;gt;}#Count)/sum({$&amp;lt;objective={'goal'}&amp;gt;}#Count),&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;id_person)&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&gt;&lt;/P&gt;&lt;P&gt;Then to break ties,you need to create a smaller value with lower work, so I think you should use:&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;=FirstSortedValue(Distinct&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;id_person,&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;aggr(sum({$&amp;lt;type={'work'}&amp;gt;}#Count)/sum({$&amp;lt;objective={'goal'}&amp;gt;}#Count) &lt;STRONG style="font-size: 12pt;"&gt;+&lt;/STRONG&gt; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;sum({$&amp;lt;type={'work'}&amp;gt;}#Count)/pow(10,9)&lt;/STRONG&gt;&lt;/SPAN&gt;,&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;id_person)&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&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 13:33:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregate-max-and-sum/m-p/1162993#M463713</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2016-06-15T13:33:35Z</dc:date>
    </item>
  </channel>
</rss>

