<?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 Help with FirstSortedValue() and Aggr() in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Help-with-FirstSortedValue-and-Aggr/m-p/588982#M218421</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to use the Aggr() function inside of FirstSortedvalue(). The only way I've ever used FirstSortedValue is on static values in a field. I'm not sure if what I want to do is possible. See below expression:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=FirstSortedValue(POSupplierNameClean, Aggr(if(Avg(PODate - PODateApproval) &amp;lt; 0, 0, Avg(PODate - PODateApproval)), POSupplierNameClean))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to average the difference in PODate and PODateApproval ("Avg. PO Days"), grouped by supplier. Once I have that average, I want to pick the supplier with the largest "Average PO Day." The expression is not calculating.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 02 May 2014 16:15:40 GMT</pubDate>
    <dc:creator />
    <dc:date>2014-05-02T16:15:40Z</dc:date>
    <item>
      <title>Help with FirstSortedValue() and Aggr()</title>
      <link>https://community.qlik.com/t5/QlikView/Help-with-FirstSortedValue-and-Aggr/m-p/588982#M218421</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to use the Aggr() function inside of FirstSortedvalue(). The only way I've ever used FirstSortedValue is on static values in a field. I'm not sure if what I want to do is possible. See below expression:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=FirstSortedValue(POSupplierNameClean, Aggr(if(Avg(PODate - PODateApproval) &amp;lt; 0, 0, Avg(PODate - PODateApproval)), POSupplierNameClean))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to average the difference in PODate and PODateApproval ("Avg. PO Days"), grouped by supplier. Once I have that average, I want to pick the supplier with the largest "Average PO Day." The expression is not calculating.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 May 2014 16:15:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-with-FirstSortedValue-and-Aggr/m-p/588982#M218421</guid>
      <dc:creator />
      <dc:date>2014-05-02T16:15:40Z</dc:date>
    </item>
    <item>
      <title>Re: Help with FirstSortedValue() and Aggr()</title>
      <link>https://community.qlik.com/t5/QlikView/Help-with-FirstSortedValue-and-Aggr/m-p/588983#M218422</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If possible, please provide sample data.&lt;/P&gt;&lt;P&gt;FirstSortedValue + Aggr &amp;gt;&amp;gt; A very good video available on QlikShare.com&lt;/P&gt;&lt;P&gt;Try to search by Aggr...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 May 2014 16:31:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-with-FirstSortedValue-and-Aggr/m-p/588983#M218422</guid>
      <dc:creator>MK_QSL</dc:creator>
      <dc:date>2014-05-02T16:31:11Z</dc:date>
    </item>
    <item>
      <title>Re: Help with FirstSortedValue() and Aggr()</title>
      <link>https://community.qlik.com/t5/QlikView/Help-with-FirstSortedValue-and-Aggr/m-p/588984#M218423</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry, I forgot to mention that this is in a text box - so there is no dimension variable. I'm not able to provide sample data for now, but the above expression should be sufficient support. If anyone notices syntax that looks incorrect, please let me know.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max(Aggr(if(Avg(PODate - PODateApproval) &amp;lt; 0, 0, Avg(PODate - PODateApproval)))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and this returns the correct value. Once I add the FirstSortedValue with SupplierNameClean, it returns Null.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 May 2014 16:37:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-with-FirstSortedValue-and-Aggr/m-p/588984#M218423</guid>
      <dc:creator />
      <dc:date>2014-05-02T16:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: Help with FirstSortedValue() and Aggr()</title>
      <link>https://community.qlik.com/t5/QlikView/Help-with-FirstSortedValue-and-Aggr/m-p/588985#M218424</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12px; background-color: #f6f6f6;"&gt;Max(Aggr(if(Avg(PODate - PODateApproval) &amp;lt; 0, 0, &lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Avg(PODate - PODateApproval)&lt;/STRONG&gt;&lt;/SPAN&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: #f6f6f6;"&gt;The highlighted part may be something like customername or suppliername or some other field&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 May 2014 16:48:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-with-FirstSortedValue-and-Aggr/m-p/588985#M218424</guid>
      <dc:creator>MK_QSL</dc:creator>
      <dc:date>2014-05-02T16:48:03Z</dc:date>
    </item>
    <item>
      <title>Re: Help with FirstSortedValue() and Aggr()</title>
      <link>https://community.qlik.com/t5/QlikView/Help-with-FirstSortedValue-and-Aggr/m-p/588986#M218425</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I figured it out. The expression needed the DISTINCT keyword in case there were multiple suppliers with the same value, as shown below:&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;"&gt;=FirstSortedValue(DISTINCT POSupplierNameClean, Aggr(if(Avg(PODate - PODateApproval) &amp;lt; 0, 0, Avg(PODate - PODateApproval)), POSupplierNameClean))&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 May 2014 16:51:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-with-FirstSortedValue-and-Aggr/m-p/588986#M218425</guid>
      <dc:creator />
      <dc:date>2014-05-02T16:51:31Z</dc:date>
    </item>
  </channel>
</rss>

