<?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 Problem in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-Problem/m-p/792248#M666032</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Brendan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Qlikview can actually solve your problem.&amp;nbsp; Make a Straight Table Chart, put the Key, Rule, Day as Dimensions and make an expression on Qty and another with the following&amp;nbsp; &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;IF (Qty &amp;gt; 0,Qty, &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;MAX( ALL AGGR (Qty,Day))) , name it Current Total and voila.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp; I usually don't do things at the script level unless necessary for performance or any other reason, because QlikView is a very powerful engine with tools and functions that can solve many of our daily work.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 27 Dec 2014 03:57:13 GMT</pubDate>
    <dc:creator />
    <dc:date>2014-12-27T03:57:13Z</dc:date>
    <item>
      <title>FirstSortedValue Problem</title>
      <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-Problem/m-p/792246#M666030</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a data set similar to the below table.&amp;nbsp; There are 3 dimensions in my table: Key, Rule, and Day.&amp;nbsp; Qty is the field/expression that represents the quantity for each given Key, Rule, and Day.&amp;nbsp; The Current Total field should represent another expression... if Qty &amp;lt;&amp;gt; -1 then display Qty, else display the last value where Qty &amp;lt;&amp;gt; -1 (and by 'last' I specifically mean the maximum day).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I use the following expression in a simple text box I get the correct result (40) that should display on all rows when Qty = -1: &lt;STRONG&gt;=FirstSortedValue({$&amp;lt;Qty = {"*"}-{"-1"}&amp;gt;}Qty,-Day)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, when I use that exact same formula in my expression in the table for the Current Total field, it returns null values instead of 40:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" height="224" style="width: 499px; height: 213px;"&gt;&lt;TBODY&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD class="xl63" height="20" style="height: 15.0pt; width: 48pt;" width="64"&gt;&lt;STRONG&gt;Key&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD class="xl63" style="width: 48pt;" width="64"&gt;&lt;STRONG&gt;Rule&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD class="xl63" style="width: 48pt;" width="64"&gt;&lt;STRONG&gt;Day&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD class="xl63" style="width: 48pt;" width="64"&gt;&lt;STRONG&gt;Qty&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD class="xl63" style="width: 95pt;" width="127"&gt;&lt;STRONG&gt;Current Total&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD height="20" style="height: 15.0pt;"&gt;ABC&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD align="right"&gt;20&lt;/TD&gt;&lt;TD align="right"&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD height="20" style="height: 15.0pt;"&gt;ABC&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD align="right"&gt;2&lt;/TD&gt;&lt;TD align="right"&gt;25&lt;/TD&gt;&lt;TD align="right"&gt;25&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD height="20" style="height: 15.0pt;"&gt;ABC&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD align="right"&gt;3&lt;/TD&gt;&lt;TD align="right"&gt;20&lt;/TD&gt;&lt;TD align="right"&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD height="20" style="height: 15.0pt;"&gt;ABC&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD align="right"&gt;4&lt;/TD&gt;&lt;TD align="right"&gt;35&lt;/TD&gt;&lt;TD align="right"&gt;35&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD height="20" style="height: 15.0pt;"&gt;ABC&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD align="right"&gt;5&lt;/TD&gt;&lt;TD align="right"&gt;40&lt;/TD&gt;&lt;TD align="right"&gt;40&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD height="20" style="height: 15.0pt;"&gt;ABC&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD align="right"&gt;6&lt;/TD&gt;&lt;TD align="right"&gt;-1&lt;/TD&gt;&lt;TD align="right" class="xl64"&gt;&lt;SPAN style="color: #ff0000;"&gt;null (should be 40)&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD height="20" style="height: 15.0pt;"&gt;ABC&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD align="right"&gt;7&lt;/TD&gt;&lt;TD align="right"&gt;-1&lt;/TD&gt;&lt;TD align="right" class="xl64"&gt;&lt;SPAN style="color: #ff0000; text-align: -webkit-right;"&gt;null (should be 40)&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 15.0pt;"&gt;&lt;TD height="20" style="height: 15.0pt;"&gt;ABC&lt;/TD&gt;&lt;TD align="right"&gt;1&lt;/TD&gt;&lt;TD align="right"&gt;8&lt;/TD&gt;&lt;TD align="right"&gt;-1&lt;/TD&gt;&lt;TD align="right" class="xl64"&gt;&lt;SPAN style="color: #ff0000; text-align: -webkit-right;"&gt;null (should be 40)&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am going to guess this has to do with aggregating data in a specific manner.&amp;nbsp; Any help would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Dec 2014 22:04:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/FirstSortedValue-Problem/m-p/792246#M666030</guid>
      <dc:creator />
      <dc:date>2014-12-26T22:04:52Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue Problem</title>
      <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-Problem/m-p/792247#M666031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The following script will give a clue to get the result.&lt;/P&gt;&lt;P&gt;load *,If(Qty= -1,Peek(Total),Qty) as Total;&lt;/P&gt;&lt;P&gt;load * Inline [&lt;/P&gt;&lt;P&gt;Key,Rule,Day,Qty&lt;/P&gt;&lt;P&gt;ABC,1,1,20&lt;/P&gt;&lt;P&gt;ABC,1,2,25&lt;/P&gt;&lt;P&gt;ABC,1,3,20&lt;/P&gt;&lt;P&gt;ABC,1,4,35&lt;/P&gt;&lt;P&gt;ABC,1,5,40&lt;/P&gt;&lt;P&gt;ABC,1,6,-1&lt;/P&gt;&lt;P&gt;ABC,1,7,-1&lt;/P&gt;&lt;P&gt;ABC,1,8,-1&lt;/P&gt;&lt;P&gt;];&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture.PNG" class="image-1 jive-image" src="https://community.qlik.com/legacyfs/online/74262_Capture.PNG" style="height: auto;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Dec 2014 23:43:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/FirstSortedValue-Problem/m-p/792247#M666031</guid>
      <dc:creator>nagaiank</dc:creator>
      <dc:date>2014-12-26T23:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue Problem</title>
      <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-Problem/m-p/792248#M666032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Brendan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Qlikview can actually solve your problem.&amp;nbsp; Make a Straight Table Chart, put the Key, Rule, Day as Dimensions and make an expression on Qty and another with the following&amp;nbsp; &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;IF (Qty &amp;gt; 0,Qty, &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;MAX( ALL AGGR (Qty,Day))) , name it Current Total and voila.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp; I usually don't do things at the script level unless necessary for performance or any other reason, because QlikView is a very powerful engine with tools and functions that can solve many of our daily work.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Dec 2014 03:57:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/FirstSortedValue-Problem/m-p/792248#M666032</guid>
      <dc:creator />
      <dc:date>2014-12-27T03:57:13Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue Problem</title>
      <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-Problem/m-p/792249#M666033</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mario,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the suggestion.&amp;nbsp; What if, however, the latest Qty is not always the largest/max value?&amp;nbsp; How would you amend your expression so that it always picks the Qty for the max/largest date?&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, 29 Dec 2014 12:44:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/FirstSortedValue-Problem/m-p/792249#M666033</guid>
      <dc:creator />
      <dc:date>2014-12-29T12:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue Problem</title>
      <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-Problem/m-p/792250#M666034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check this&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Dec 2014 13:05:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/FirstSortedValue-Problem/m-p/792250#M666034</guid>
      <dc:creator>anbu1984</dc:creator>
      <dc:date>2014-12-29T13:05:01Z</dc:date>
    </item>
  </channel>
</rss>

