<?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: Having difficulty with working aggr function in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Having-difficulty-with-working-aggr-function/m-p/486906#M483093</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try: firstsortedvalue(ReportStatus,-ModifiedDate)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 Jul 2013 16:38:15 GMT</pubDate>
    <dc:creator>Gysbert_Wassenaar</dc:creator>
    <dc:date>2013-07-16T16:38:15Z</dc:date>
    <item>
      <title>Having difficulty with working aggr function</title>
      <link>https://community.qlik.com/t5/QlikView/Having-difficulty-with-working-aggr-function/m-p/486905#M483092</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&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;P&gt;LOAD * Inline&lt;/P&gt;&lt;P&gt;[&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;UserId, ModifiedDate, ReportStatus&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;204190,6/12/2012,Completed&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;204190,1/22/2013,Waiting for Screening&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to return the latest ReportStatus based on UserId.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is my aggr function, which has no problem returning the date, but once I try to add in ReportStatus, the function returns nothing:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Works:&lt;/P&gt;&lt;P&gt;=Aggr(max(ModifiedDate), UserId)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Doesn't work, but need it to!&lt;/P&gt;&lt;P&gt;=if(Aggr(max(ModifiedDate), UserId), ReportStatus)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm pounding my head against the desk trying to figure out why this doesn't work!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 16:25:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Having-difficulty-with-working-aggr-function/m-p/486905#M483092</guid>
      <dc:creator />
      <dc:date>2013-07-16T16:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: Having difficulty with working aggr function</title>
      <link>https://community.qlik.com/t5/QlikView/Having-difficulty-with-working-aggr-function/m-p/486906#M483093</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try: firstsortedvalue(ReportStatus,-ModifiedDate)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 16:38:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Having-difficulty-with-working-aggr-function/m-p/486906#M483093</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2013-07-16T16:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: Having difficulty with working aggr function</title>
      <link>https://community.qlik.com/t5/QlikView/Having-difficulty-with-working-aggr-function/m-p/486907#M483094</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That worked, thank you! Maybe I was over-thinking it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to only display the expression if the user selects a UserId?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 16:53:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Having-difficulty-with-working-aggr-function/m-p/486907#M483094</guid>
      <dc:creator />
      <dc:date>2013-07-16T16:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: Having difficulty with working aggr function</title>
      <link>https://community.qlik.com/t5/QlikView/Having-difficulty-with-working-aggr-function/m-p/486908#M483095</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if(getselectedcount(UserId)=1, firstsortedvalue(ReportStatus,-ModifiedDate))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 16:59:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Having-difficulty-with-working-aggr-function/m-p/486908#M483095</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2013-07-16T16:59:46Z</dc:date>
    </item>
    <item>
      <title>Re: Having difficulty with working aggr function</title>
      <link>https://community.qlik.com/t5/QlikView/Having-difficulty-with-working-aggr-function/m-p/486909#M483096</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey I have one more scenario where this didn't pick the right thing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this case, the timestamp/date is identical down to the second but one has 0 value and the other has some number value.&amp;nbsp; I've tried a variety of approaches to make it pick the one with the value- including an attempt to exclude the 0 value in the script that QV somehow ignored.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyone have an idea for firstsorted(fieldname, -date) that would pick the greatest value of that fieldname if the date was identical down to the second?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;firstsortedvalue(firstsortedvalue(fieldname, -date), -fieldname)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(That formula didn't actually work, but it's correct logically I think.)&lt;/P&gt;&lt;P&gt;-----------Update----------------------------&lt;/P&gt;&lt;P&gt;Update this did the trick: firstsortedvalue(fieldname, -(date+fieldname))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So now it is date + fieldname value, and if fieldname value is 0 it loses. &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;Also I had one that was a fieldname concatenated with text concatenate with another fieldname (blood pressure) and I just had it go with &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;firstsortedvalue(fieldname, -(date+fieldname/fieldname2)) //one of the fields had a 0 and another had a bogus high number, so I used divide to make it remove itself and yield to some real value on the same timestamp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;----update update----&lt;/P&gt;&lt;P&gt;and date+fieldname won't work if the timestamp matches to the second and the fieldnames have identical values.&amp;nbsp; Solving this was a matter of adding a bunch of other related fieldnames that might have 0 on the less complete record from one source and values on the complete record from a parallel source to make QlikView just pick one rather than give another null.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway, I think that solves for almost every loose end now.&amp;nbsp; If all the number values across the span of fields were identical, we might figure a way to have it look at the greater alphabetical value of the two sources....&amp;nbsp; nest if statements or something...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gysbert's solution was great to throw around. &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 20:04:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Having-difficulty-with-working-aggr-function/m-p/486909#M483096</guid>
      <dc:creator>stevelord</dc:creator>
      <dc:date>2013-07-16T20:04:41Z</dc:date>
    </item>
  </channel>
</rss>

