<?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: neither firstsortedvalue nor max(testdate) getting desired result in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/neither-firstsortedvalue-nor-max-testdate-getting-desired-result/m-p/489287#M182858</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Alright! I figured it out while complaining to my boss over IM. &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt; My aggr statement was just missing a couple of related fields needed for its grouping/group by framework.&amp;nbsp; Table didn't change until the last field of the group by was snapped into place.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So it was blahblahblah, Count(Aggr(max/firstsorted(whateverthing), UserId, &lt;SPAN style="text-decoration: underline;"&gt;Source, TestYear)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I was just short on listing fields to group it by for the aggr function.&amp;nbsp; And if you have a table that doesnt change when you switch between min/max or +/-, you can check and add things to your aggr fields and save alot of money by switching to gecko. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS&amp;gt; I spent another half hour experimenting to confirm this.&amp;nbsp; Table goes back to ignoring me when I take one of the underlined aggr fields back out and back to correct when I put the fields back in.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 19 Jun 2013 19:19:10 GMT</pubDate>
    <dc:creator>stevelord</dc:creator>
    <dc:date>2013-06-19T19:19:10Z</dc:date>
    <item>
      <title>neither firstsortedvalue nor max(testdate) getting desired result</title>
      <link>https://community.qlik.com/t5/QlikView/neither-firstsortedvalue-nor-max-testdate-getting-desired-result/m-p/489286#M182857</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi I've tried these two formulas on a pivot table and get 'Expression Ok' from Qlikview, but my testdate column is picking the february test when it has a choice between february and march 2012 tests.&amp;nbsp; I have a separate tablebox with userid, testdate, and testvalues with all dates/values showing to compare my pivot table to.&amp;nbsp; Strangely, my pivot table doesn't seem to change whether I have the - or not in firstsortedvalue, and whether I have max(TestDate) or min(TestDate)&amp;nbsp; Any idea what could cause this?&amp;nbsp; Whatever the data source, it seems to me that toggling the - sign or toggling min/max on TestDate should make the table change.. (Yes, I pushed apply and okay. &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;Dimensions: ClientName(left out of below view), UserId (ficticious), TestDate&lt;/P&gt;&lt;P&gt;Expressions tried all produced the tables shown below::&lt;/P&gt;&lt;P&gt;if([rbTotal Cholesterol],Count(aggr(firstsortedvalue([rbTotal Cholesterol],-1*TestDate), UserId)))&lt;/P&gt;&lt;P&gt;if([rbTotal Cholesterol],Count(aggr(firstsortedvalue([rbTotal Cholesterol],TestDate), UserId)))&lt;/P&gt;&lt;P&gt;if([rbTotal Cholesterol],Count(aggr(max(TestDate), UserId)))&lt;/P&gt;&lt;P&gt;if([rbTotal Cholesterol],Count(aggr(min(TestDate), UserId)))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The if might not be needed on firstsortedvalue- it just sort of carried over from when I tried max(TestDate)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 384px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD colspan="2" height="19" width="128"&gt;PivotTable&lt;/TD&gt;&lt;TD width="64"&gt;&lt;/TD&gt;&lt;TD width="64"&gt;&lt;/TD&gt;&lt;TD width="64"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="19"&gt;UserId&lt;/TD&gt;&lt;TD&gt;TestDate&lt;/TD&gt;&lt;TD&gt;[rbTotal Cholesterol]&lt;/TD&gt;&lt;TD&gt;Optimal&lt;/TD&gt;&lt;TD&gt;Borderline&lt;/TD&gt;&lt;TD&gt;Out of Range&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="19" width="64"&gt;702&lt;/TD&gt;&lt;TD class="xl64" style="border-left: none;" width="64"&gt;2/14/2012&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="64"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-left: none;" width="64"&gt; &lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="xl66" style="border-left: none;" width="64"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="19" style="border-top: none;" width="64"&gt;708&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;" width="64"&gt;2/14/2012&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;" width="64"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;" width="64"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;" width="64"&gt; &lt;/TD&gt;&lt;TD class="xl67" style="border-top: none; border-left: none;" width="64"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="19" style="border-top: none;" width="64"&gt;711&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;" width="64"&gt;2/14/2012&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;" width="64"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;" width="64"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;" width="64"&gt; &lt;/TD&gt;&lt;TD class="xl67" style="border-top: none; border-left: none;" width="64"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="19" style="border-top: none;" width="64"&gt;716&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;" width="64"&gt;2/14/2012&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;" width="64"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;" width="64"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;" width="64"&gt; &lt;/TD&gt;&lt;TD class="xl67" style="border-top: none; border-left: none;" width="64"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="19" style="border-top: none;" width="64"&gt;718&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;" width="64"&gt;2/14/2012&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;" width="64"&gt; &lt;/TD&gt;&lt;TD class="xl67" style="border-top: none; border-left: none;" width="64"&gt;1&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;" width="64"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;" width="64"&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="19" style="border-top: none;" width="64"&gt;719&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;" width="64"&gt;2/14/2012&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;" width="64"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;" width="64"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;" width="64"&gt; &lt;/TD&gt;&lt;TD class="xl67" style="border-top: none; border-left: none;" width="64"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl63" height="19" style="border-top: none;" width="64"&gt;720&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;" width="64"&gt;2/14/2012&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;" width="64"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;" width="64"&gt; &lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;" width="64"&gt; &lt;/TD&gt;&lt;TD class="xl67" style="border-top: none; border-left: none;" width="64"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tablebox&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 275px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD height="19" width="64"&gt;UserId&lt;/TD&gt;&lt;TD width="64"&gt;TestDate&lt;/TD&gt;&lt;TD&gt;[rbTotal Cholesterol]&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="19" width="64"&gt;702&lt;/TD&gt;&lt;TD class="xl66" style="border-left: none;" width="64"&gt;2/14/2012&lt;/TD&gt;&lt;TD class="xl67" style="border-left: none;" width="147"&gt;Borderline&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="19" style="border-top: none;" width="64"&gt;702&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;" width="64"&gt;2/16/2012&lt;/TD&gt;&lt;TD class="xl67" style="border-top: none; border-left: none;" width="147"&gt;Out of Range&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="19" style="border-top: none;" width="64"&gt;702&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;" width="64"&gt;3/15/2012&lt;/TD&gt;&lt;TD class="xl67" style="border-top: none; border-left: none;" width="147"&gt;Out of Range&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="19" style="border-top: none;" width="64"&gt;708&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;" width="64"&gt;2/14/2012&lt;/TD&gt;&lt;TD class="xl67" style="border-top: none; border-left: none;" width="147"&gt;Out of Range&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="19" style="border-top: none;" width="64"&gt;708&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;" width="64"&gt;3/15/2012&lt;/TD&gt;&lt;TD class="xl67" style="border-top: none; border-left: none;" width="147"&gt;Borderline&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="19" style="border-top: none;" width="64"&gt;711&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;" width="64"&gt;2/14/2012&lt;/TD&gt;&lt;TD class="xl67" style="border-top: none; border-left: none;" width="147"&gt;Out of Range&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="19" style="border-top: none;" width="64"&gt;711&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;" width="64"&gt;3/15/2012&lt;/TD&gt;&lt;TD class="xl67" style="border-top: none; border-left: none;" width="147"&gt;Optimal&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="19" style="border-top: none;" width="64"&gt;716&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;" width="64"&gt;2/14/2012&lt;/TD&gt;&lt;TD class="xl67" style="border-top: none; border-left: none;" width="147"&gt;Out of Range&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="19" style="border-top: none;" width="64"&gt;716&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;" width="64"&gt;3/15/2012&lt;/TD&gt;&lt;TD class="xl67" style="border-top: none; border-left: none;" width="147"&gt;Optimal &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="19" style="border-top: none;" width="64"&gt;718&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;" width="64"&gt;2/14/2012&lt;/TD&gt;&lt;TD class="xl67" style="border-top: none; border-left: none;" width="147"&gt;Optimal&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="19" style="border-top: none;" width="64"&gt;718&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;" width="64"&gt;3/5/2012&lt;/TD&gt;&lt;TD class="xl67" style="border-top: none; border-left: none;" width="147"&gt;Optimal &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="19" style="border-top: none;" width="64"&gt;718&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;" width="64"&gt;3/15/2012&lt;/TD&gt;&lt;TD class="xl67" style="border-top: none; border-left: none;" width="147"&gt;Optimal&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="19" style="border-top: none;" width="64"&gt;719&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;" width="64"&gt;2/14/2012&lt;/TD&gt;&lt;TD class="xl67" style="border-top: none; border-left: none;" width="147"&gt;Out of Range&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="19" style="border-top: none;" width="64"&gt;719&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;" width="64"&gt;3/15/2012&lt;/TD&gt;&lt;TD class="xl67" style="border-top: none; border-left: none;" width="147"&gt;Out of Range&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="19" style="border-top: none;" width="64"&gt;720&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;" width="64"&gt;2/14/2012&lt;/TD&gt;&lt;TD class="xl67" style="border-top: none; border-left: none;" width="147"&gt;Out of Range&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="19" style="border-top: none;" width="64"&gt;720&lt;/TD&gt;&lt;TD class="xl66" style="border-top: none; border-left: none;" width="64"&gt;3/15/2012&lt;/TD&gt;&lt;TD class="xl67" style="border-top: none; border-left: none;" width="147"&gt;Optimal&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;Note: Total Cholesterol field was created by a SUM(if(TestName='Total Cholesterol',TestValue)) as [Total Cholesterol] in a table grouped by Client, UserId, Date(Floor(TestDate)), and Year(TestDate).&amp;nbsp; The [rbTotal Cholesterol] was part of a subsequent resident load for if([Total Cholesterol]&amp;lt;200, dual('Optimal','Optimal'),.... etc as [rbTotal Cholesterol]&amp;nbsp; The original qvd file had columns UserId, TestName, TestValue, TestDate.&amp;nbsp; I worried about dates losing their links to the tests, but the tablebox looks okay in that regard and I only have one TestDate field available....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jun 2013 17:50:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/neither-firstsortedvalue-nor-max-testdate-getting-desired-result/m-p/489286#M182857</guid>
      <dc:creator>stevelord</dc:creator>
      <dc:date>2013-06-19T17:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: neither firstsortedvalue nor max(testdate) getting desired result</title>
      <link>https://community.qlik.com/t5/QlikView/neither-firstsortedvalue-nor-max-testdate-getting-desired-result/m-p/489287#M182858</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Alright! I figured it out while complaining to my boss over IM. &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt; My aggr statement was just missing a couple of related fields needed for its grouping/group by framework.&amp;nbsp; Table didn't change until the last field of the group by was snapped into place.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So it was blahblahblah, Count(Aggr(max/firstsorted(whateverthing), UserId, &lt;SPAN style="text-decoration: underline;"&gt;Source, TestYear)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I was just short on listing fields to group it by for the aggr function.&amp;nbsp; And if you have a table that doesnt change when you switch between min/max or +/-, you can check and add things to your aggr fields and save alot of money by switching to gecko. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS&amp;gt; I spent another half hour experimenting to confirm this.&amp;nbsp; Table goes back to ignoring me when I take one of the underlined aggr fields back out and back to correct when I put the fields back in.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jun 2013 19:19:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/neither-firstsortedvalue-nor-max-testdate-getting-desired-result/m-p/489287#M182858</guid>
      <dc:creator>stevelord</dc:creator>
      <dc:date>2013-06-19T19:19:10Z</dc:date>
    </item>
  </channel>
</rss>

