<?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 Using Sets, FirstSortedValue and Aggr in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Using-Sets-FirstSortedValue-and-Aggr/m-p/267071#M497862</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I am trying to count the latest specific grades for a range of ServiceName(s). I have got as far as the following, which gives me the count for the most recent Service for the most recent date, but zeroes for the other ServiceNames, as expected. I have been struggling as to how I should aggr() this for a&amp;nbsp; range of ServiceName(s): &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;=(Count({&amp;lt;QAFID={'$(=FirstSortedValue(QAFID,-LAValOrSelfAssessDate))'},AssessmentSupportPlanning={"A"}&amp;gt;}DISTINCT QAFID)+&lt;/P&gt;&lt;P&gt;Count({&amp;lt;QAFID={'$(=FirstSortedValue(QAFID,-LAValOrSelfAssessDate))'},ClientInvolvementEmpowerment={"A"}&amp;gt;}DISTINCT QAFID)+&lt;/P&gt;&lt;P&gt;Count({&amp;lt;QAFID={'$(=FirstSortedValue(QAFID,-LAValOrSelfAssessDate))'},Complaints={"A"}&amp;gt;}DISTINCT QAFID)+&lt;/P&gt;&lt;P&gt;Count({&amp;lt;QAFID={'$(=FirstSortedValue(QAFID,-LAValOrSelfAssessDate))'},FairAccessDiversityInclusion={"A"}&amp;gt;}DISTINCT QAFID)+&lt;/P&gt;&lt;P&gt;Count({&amp;lt;QAFID={'$(=FirstSortedValue(QAFID,-LAValOrSelfAssessDate))'},NeedsRiskAssessment={"A"}&amp;gt;}DISTINCT QAFID)+&lt;/P&gt;&lt;P&gt;Count({&amp;lt;QAFID={'$(=FirstSortedValue(QAFID,-LAValOrSelfAssessDate))'},ProtectionFromAbuse={"A"}&amp;gt;}DISTINCT QAFID)+&lt;/P&gt;&lt;P&gt;Count({&amp;lt;QAFID={'$(=FirstSortedValue(QAFID,-LAValOrSelfAssessDate))'},SafeGuardingProtectionAbuse={"A"}&amp;gt;}DISTINCT QAFID)+&lt;/P&gt;&lt;P&gt;Count({&amp;lt;QAFID={'$(=FirstSortedValue(QAFID,-LAValOrSelfAssessDate))'},SecurityHealthSafety={"A"}&amp;gt;}DISTINCT QAFID)+&lt;/P&gt;&lt;P&gt;Count({&amp;lt;QAFID={'$(=FirstSortedValue(QAFID,-LAValOrSelfAssessDate))'},SupportPlanning={"A"}&amp;gt;}DISTINCT QAFID))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;Thanks in advance for your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 11 Aug 2011 16:21:47 GMT</pubDate>
    <dc:creator />
    <dc:date>2011-08-11T16:21:47Z</dc:date>
    <item>
      <title>Using Sets, FirstSortedValue and Aggr</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Sets-FirstSortedValue-and-Aggr/m-p/267071#M497862</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I am trying to count the latest specific grades for a range of ServiceName(s). I have got as far as the following, which gives me the count for the most recent Service for the most recent date, but zeroes for the other ServiceNames, as expected. I have been struggling as to how I should aggr() this for a&amp;nbsp; range of ServiceName(s): &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;=(Count({&amp;lt;QAFID={'$(=FirstSortedValue(QAFID,-LAValOrSelfAssessDate))'},AssessmentSupportPlanning={"A"}&amp;gt;}DISTINCT QAFID)+&lt;/P&gt;&lt;P&gt;Count({&amp;lt;QAFID={'$(=FirstSortedValue(QAFID,-LAValOrSelfAssessDate))'},ClientInvolvementEmpowerment={"A"}&amp;gt;}DISTINCT QAFID)+&lt;/P&gt;&lt;P&gt;Count({&amp;lt;QAFID={'$(=FirstSortedValue(QAFID,-LAValOrSelfAssessDate))'},Complaints={"A"}&amp;gt;}DISTINCT QAFID)+&lt;/P&gt;&lt;P&gt;Count({&amp;lt;QAFID={'$(=FirstSortedValue(QAFID,-LAValOrSelfAssessDate))'},FairAccessDiversityInclusion={"A"}&amp;gt;}DISTINCT QAFID)+&lt;/P&gt;&lt;P&gt;Count({&amp;lt;QAFID={'$(=FirstSortedValue(QAFID,-LAValOrSelfAssessDate))'},NeedsRiskAssessment={"A"}&amp;gt;}DISTINCT QAFID)+&lt;/P&gt;&lt;P&gt;Count({&amp;lt;QAFID={'$(=FirstSortedValue(QAFID,-LAValOrSelfAssessDate))'},ProtectionFromAbuse={"A"}&amp;gt;}DISTINCT QAFID)+&lt;/P&gt;&lt;P&gt;Count({&amp;lt;QAFID={'$(=FirstSortedValue(QAFID,-LAValOrSelfAssessDate))'},SafeGuardingProtectionAbuse={"A"}&amp;gt;}DISTINCT QAFID)+&lt;/P&gt;&lt;P&gt;Count({&amp;lt;QAFID={'$(=FirstSortedValue(QAFID,-LAValOrSelfAssessDate))'},SecurityHealthSafety={"A"}&amp;gt;}DISTINCT QAFID)+&lt;/P&gt;&lt;P&gt;Count({&amp;lt;QAFID={'$(=FirstSortedValue(QAFID,-LAValOrSelfAssessDate))'},SupportPlanning={"A"}&amp;gt;}DISTINCT QAFID))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;Thanks in advance for your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Aug 2011 16:21:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Sets-FirstSortedValue-and-Aggr/m-p/267071#M497862</guid>
      <dc:creator />
      <dc:date>2011-08-11T16:21:47Z</dc:date>
    </item>
    <item>
      <title>Using Sets, FirstSortedValue and Aggr</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Sets-FirstSortedValue-and-Aggr/m-p/267072#M497863</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;looks like you managed to over-complicate your problem &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/wink.png" /&gt; How about this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum( &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AGGR(&lt;/P&gt;&lt;P&gt;&lt;CODE class="jive-code"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Count({&amp;lt;QAFID={'$(=FirstSortedValue(QAFID,-&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LAValOrSelfAssessDate))'}&amp;gt;}DISTINCT QAFID))&lt;/CODE&gt; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , ServiceName)&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Aug 2011 18:42:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Sets-FirstSortedValue-and-Aggr/m-p/267072#M497863</guid>
      <dc:creator>Oleg_Troyansky</dc:creator>
      <dc:date>2011-08-11T18:42:00Z</dc:date>
    </item>
    <item>
      <title>Using Sets, FirstSortedValue and Aggr</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Sets-FirstSortedValue-and-Aggr/m-p/267073#M497864</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your reply Oleg, but unfortunately that is not what I was after.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To clarify, I am grouping the grades, so as above that should calculate for all the grades marked "A".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem I am having is that I need the fragment:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; {&amp;lt;QAFID={'$(=FirstSortedValue(QAFID,-LAValOrSelfAssessDate))'},AssessmentSupportPlanning={"A"}&amp;gt;}DISTINCT QAFID&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;not just to pick up the FirstSortedValue for the entire dataset, but each QAFID for the last LAValOrSelfAssessDate &lt;EM&gt;per ServiceName.&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Aug 2011 09:29:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Sets-FirstSortedValue-and-Aggr/m-p/267073#M497864</guid>
      <dc:creator />
      <dc:date>2011-08-12T09:29:28Z</dc:date>
    </item>
    <item>
      <title>Using Sets, FirstSortedValue and Aggr</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Sets-FirstSortedValue-and-Aggr/m-p/267074#M497865</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah, OK, then you need to structure your Set Analysis condition around the date and not around the QAFID. Your verbal definition of the problem determines what field to use in Set Analysis:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"I need the last QAFID" - busind a condition based on QAFID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"Ineed all QUAFID records associated with the latest date - build your condition on the Date field:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LAValOrSelfAssessDate ={ $(=date(max(LAValOrSelfAssessDate))) }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;including this into an AGGR by ServiceName will actually ensure that the latest date is selected by ServiceName.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Aug 2011 16:02:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Sets-FirstSortedValue-and-Aggr/m-p/267074#M497865</guid>
      <dc:creator>Oleg_Troyansky</dc:creator>
      <dc:date>2011-08-12T16:02:10Z</dc:date>
    </item>
    <item>
      <title>Re: Using Sets, FirstSortedValue and Aggr</title>
      <link>https://community.qlik.com/t5/QlikView/Using-Sets-FirstSortedValue-and-Aggr/m-p/267075#M497866</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for this, it might come in helpful, but I have found a simpler solution that works for me:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if(FirstSortedValue(AssessmentSupportPlanning,-LAValOrSelfAssessDate)='A',1,0) +&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(in a chart per service)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sum(Aggr(if(FirstSortedValue(AssessmentSupportPlanning,-LAValOrSelfAssessDate)='A',1,0),ServiceName))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(as a partial of an overall sum)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Aug 2011 10:35:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-Sets-FirstSortedValue-and-Aggr/m-p/267075#M497866</guid>
      <dc:creator />
      <dc:date>2011-08-15T10:35:35Z</dc:date>
    </item>
  </channel>
</rss>

