<?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: FirstSortedValue - Based on Max Value in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-Based-on-Max-Value/m-p/1008329#M342345</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this expression:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FirstSortedValue(Player,-Aggr(SUM({$&amp;lt;pos={'TE'}&amp;gt;}pts),def, wk, pos, Player))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="103710" alt="Capture.PNG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/103710_Capture.PNG" style="height: 121px; width: 620px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 Nov 2015 12:12:47 GMT</pubDate>
    <dc:creator>sunny_talwar</dc:creator>
    <dc:date>2015-11-02T12:12:47Z</dc:date>
    <item>
      <title>FirstSortedValue - Based on Max Value</title>
      <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-Based-on-Max-Value/m-p/1008327#M342343</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am struggling with the following issue.&amp;nbsp; I have attached a sample qvw.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a simple table, which breaks down weekly stats for a team.&amp;nbsp; I have a chart that has three dimensions, then does a sum of points.&amp;nbsp; What I'm trying to add is a second expression that shows the player who had the maximum points for the given week.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have used the FirstSortedValue function and it appears to work, but there is one week where it does not display the correct player.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the attached, you will see the table and chart.&amp;nbsp; I can't figure out why the function returns 'Timothy Wright' in week 7, when it should return 'Eric Ebron' because he had 14.9 pts vs 1.3 for Wright.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Perhaps I should be using an entirely different approach?&amp;nbsp; Please keep in mind this is a small snapshot of the overall dataset, just to illustrate the issue.&amp;nbsp; I have a set analysis built into the expression to show the function as it is in my actual qvw file (even though it is not needed for this small sample).&amp;nbsp; Not sure if it makes a difference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2015 12:06:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/FirstSortedValue-Based-on-Max-Value/m-p/1008327#M342343</guid>
      <dc:creator>jzimolong</dc:creator>
      <dc:date>2015-11-02T12:06:05Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue - Based on Max Value</title>
      <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-Based-on-Max-Value/m-p/1008328#M342344</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Joseph, try adding week to the Aggr() function:&lt;/P&gt;&lt;P&gt;FirstSortedValue(DISTINCT Player,-Aggr(SUM({$&amp;lt;pos={'TE'}&amp;gt;}pts),&lt;STRONG&gt;wk&lt;/STRONG&gt;,Player))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2015 12:12:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/FirstSortedValue-Based-on-Max-Value/m-p/1008328#M342344</guid>
      <dc:creator>rubenmarin</dc:creator>
      <dc:date>2015-11-02T12:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue - Based on Max Value</title>
      <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-Based-on-Max-Value/m-p/1008329#M342345</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this expression:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FirstSortedValue(Player,-Aggr(SUM({$&amp;lt;pos={'TE'}&amp;gt;}pts),def, wk, pos, Player))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="103710" alt="Capture.PNG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/103710_Capture.PNG" style="height: 121px; width: 620px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2015 12:12:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/FirstSortedValue-Based-on-Max-Value/m-p/1008329#M342345</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2015-11-02T12:12:47Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue - Based on Max Value</title>
      <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-Based-on-Max-Value/m-p/1008330#M342346</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Ruben and Sunny, I didn't realize you could add multiple columns in the Aggr function.&amp;nbsp; This fixed the issue I was experiencing, and uncovered another.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I changed the data for wk 7, making the points equal for both Ebron and Wright.&amp;nbsp; Now, the function comes back as NULL as it doesn't know which one to display.&amp;nbsp; Could it be forced to pick one (perhaps based on the alpha sort on Player)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is updated load script.&amp;nbsp; I couldn't not repost the sample qvw.&amp;nbsp; Chart now shows NULL for week 7.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;PlayerData:&lt;BR /&gt; &lt;/SPAN&gt;&lt;STRONG style=": ; color: #0000ff; font-size: 8pt;"&gt;load&lt;/STRONG&gt;&lt;SPAN style="font-size: 8pt;"&gt; * &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;inline&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;[&lt;BR /&gt; def, wk, pos, Player, pts&lt;BR /&gt; MIN, 1, TE, Vernon Davis, 4.7&lt;BR /&gt; MIN, 1, TE, Garrett Celek, 4&lt;BR /&gt; MIN, 1, TE, Vance McDonald, 0.5&lt;BR /&gt; MIN, 2, TE, Eric Ebron, 10.3&lt;BR /&gt; MIN, 3, TE, John Phillips, 3.5&lt;BR /&gt; MIN, 3, TE, David Johnson, 0.2&lt;BR /&gt; MIN, 4, TE, Owen Daniels, 6.9&lt;BR /&gt; MIN, 6, TE, Travis Kelce, 8.8&lt;BR /&gt; MIN, 6, TE, James O'Shaughnessy, 2.3&lt;BR /&gt; MIN, 6, TE, Demetrius Harris, 1.5&lt;BR /&gt; MIN, 7, TE, Eric Ebron, 7&lt;BR /&gt; MIN, 7, TE, Timothy Wright, 7&lt;BR /&gt; ]&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2015 12:28:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/FirstSortedValue-Based-on-Max-Value/m-p/1008330#M342346</guid>
      <dc:creator>jzimolong</dc:creator>
      <dc:date>2015-11-02T12:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue - Based on Max Value</title>
      <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-Based-on-Max-Value/m-p/1008331#M342347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Distinct should help in that case:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FirstSortedValue(DISTINCT Player,-Aggr(SUM({$&amp;lt;pos={'TE'}&amp;gt;}pts),def, wk, pos, Player))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture.PNG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/103711_Capture.PNG" style="height: 195px; width: 620px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2015 12:31:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/FirstSortedValue-Based-on-Max-Value/m-p/1008331#M342347</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2015-11-02T12:31:31Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue - Based on Max Value</title>
      <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-Based-on-Max-Value/m-p/1008332#M342348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Joseph, same expression works for me:&lt;/P&gt;&lt;P&gt;FirstSortedValue(DISTINCT Player,-Aggr(SUM({$&amp;lt;pos={'TE'}&amp;gt;}pts),&lt;STRONG&gt;wk&lt;/STRONG&gt;,Player))&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jive-image image-2" src="https://community.qlik.com/legacyfs/online/103712_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jive-image image-1" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2015 12:33:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/FirstSortedValue-Based-on-Max-Value/m-p/1008332#M342348</guid>
      <dc:creator>rubenmarin</dc:creator>
      <dc:date>2015-11-02T12:33:36Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue - Based on Max Value</title>
      <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-Based-on-Max-Value/m-p/1008333#M342349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Ruben, you had the DISTINCT in there all along.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2015 12:37:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/FirstSortedValue-Based-on-Max-Value/m-p/1008333#M342349</guid>
      <dc:creator>jzimolong</dc:creator>
      <dc:date>2015-11-02T12:37:10Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue - Based on Max Value</title>
      <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-Based-on-Max-Value/m-p/1008334#M342350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Sunny, appreciate the quick replies.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2015 12:38:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/FirstSortedValue-Based-on-Max-Value/m-p/1008334#M342350</guid>
      <dc:creator>jzimolong</dc:creator>
      <dc:date>2015-11-02T12:38:05Z</dc:date>
    </item>
  </channel>
</rss>

