<?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: Need help with FirstSortedValue - Negative count upto latest positive value in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Need-help-with-FirstSortedValue-Negative-count-upto-latest/m-p/1163285#M378978</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;‌Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That's the way the source file is. the objective is to obtain the first positive amount starting with the max date in descending order And then counting the negative amounts for a client currency grouping up to the date obtained earlier. I need this in the front end so that user can select date.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Appreciate your help on this!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 17 May 2016 19:45:44 GMT</pubDate>
    <dc:creator>sanadm19</dc:creator>
    <dc:date>2016-05-17T19:45:44Z</dc:date>
    <item>
      <title>Need help with FirstSortedValue - Negative count upto latest positive value</title>
      <link>https://community.qlik.com/t5/QlikView/Need-help-with-FirstSortedValue-Negative-count-upto-latest/m-p/1163283#M378976</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know this should be easy but I've spent hours and just not getting anywhere.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a table looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;DATE&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;CLIENT&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;CURRENCY&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;AMOUNT&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;01/01/2016&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;P&gt;ABC&lt;/P&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;USD&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;-250&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;10/01/2016&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;ABC&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;USD&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;-151&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;14/01/2016&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;ABC&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;USD&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;190&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;01/01/2016&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;ABC&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;EUR&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;185&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;27/01/2016&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;ABC&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;EUR&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;-25&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;10/01/2016&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;DEF&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;GBP&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;-100&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;30/01/2016&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;DEF&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;GBP&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need an expression to count the number of negative amounts from the starting date up to the date with the latest positive amount. So the result should look like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ABC USD 2&lt;/P&gt;&lt;P&gt;ABC EUR 0&lt;/P&gt;&lt;P&gt;DEF GBP 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to use FirstSortedValue(DATE,if(AMOUNT&amp;gt;=0,AMOUNT))&amp;nbsp;&amp;nbsp; but it isn't working.&lt;/P&gt;&lt;P&gt;Any help will be appreciated. sample qvw is attached.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2016 15:17:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Need-help-with-FirstSortedValue-Negative-count-upto-latest/m-p/1163283#M378976</guid>
      <dc:creator>sanadm19</dc:creator>
      <dc:date>2016-05-17T15:17:26Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with FirstSortedValue - Negative count upto latest positive value</title>
      <link>https://community.qlik.com/t5/QlikView/Need-help-with-FirstSortedValue-Negative-count-upto-latest/m-p/1163284#M378977</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;On a given date, you have multiple records per Client and Currency, some negative and some positive. How do you determine which record comes first?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, do you need the solution in the frontend or can it be solved in the script?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If latter, please provide a sample input file (potentially with added time stamps).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2016 15:42:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Need-help-with-FirstSortedValue-Negative-count-upto-latest/m-p/1163284#M378977</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2016-05-17T15:42:56Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with FirstSortedValue - Negative count upto latest positive value</title>
      <link>https://community.qlik.com/t5/QlikView/Need-help-with-FirstSortedValue-Negative-count-upto-latest/m-p/1163285#M378978</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;‌Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That's the way the source file is. the objective is to obtain the first positive amount starting with the max date in descending order And then counting the negative amounts for a client currency grouping up to the date obtained earlier. I need this in the front end so that user can select date.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Appreciate your help on this!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2016 19:45:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Need-help-with-FirstSortedValue-Negative-count-upto-latest/m-p/1163285#M378978</guid>
      <dc:creator>sanadm19</dc:creator>
      <dc:date>2016-05-17T19:45:44Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with FirstSortedValue - Negative count upto latest positive value</title>
      <link>https://community.qlik.com/t5/QlikView/Need-help-with-FirstSortedValue-Negative-count-upto-latest/m-p/1163286#M378979</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __default_attr="sql" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_1463517043070187 jive_text_macro" jivemacro_uid="_1463517043070187"&gt;
&lt;P&gt;SET DateFormat='D/M/YYYY';&lt;/P&gt;
&lt;P&gt;Data:&lt;/P&gt;
&lt;P&gt;Load *, If(Previous(CLIENT)=CLIENT And CURRENCY=Previous(CURRENCY),&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(Previous(AMOUNT)&amp;lt;0,AMOUNT&amp;lt;0,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,AMOUNT&amp;lt;0) As Flag;&lt;/P&gt;
&lt;P&gt;LOAD * INLINE [&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DATE, CLIENT, CURRENCY, AMOUNT&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01/01/2016, ABC, USD, -250&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10/01/2016, ABC, USD, -151&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 14/01/2016, ABC, USD, 190&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01/01/2016, ABC, EUR, 185&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 27/01/2016, ABC, EUR, -25&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10/01/2016, DEF, GBP, -100&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 30/01/2016, DEF, GBP, 0&lt;/P&gt;
&lt;P&gt;];&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;IMG alt="CaptureX.PNG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/124848_CaptureX.PNG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;PFA..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2016 20:31:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Need-help-with-FirstSortedValue-Negative-count-upto-latest/m-p/1163286#M378979</guid>
      <dc:creator>Saravanan_Desingh</dc:creator>
      <dc:date>2016-05-17T20:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with FirstSortedValue - Negative count upto latest positive value</title>
      <link>https://community.qlik.com/t5/QlikView/Need-help-with-FirstSortedValue-Negative-count-upto-latest/m-p/1163287#M378980</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Will still have to see how it goes with the actual data, but one modification i would propose is to sort the data in a resident load before using Peek/Previous. The reason I say this is because the sample provided here might be sorted in a desired format, whereas original data may differ from this which will end up giving incorrect output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SET DateFormat='DD/MM/YYYY';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Data:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD * INLINE [&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DATE, CLIENT, CURRENCY, AMOUNT&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01/01/2016, ABC, USD, -250&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10/01/2016, ABC, USD, -151&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 14/01/2016, ABC, USD, 190&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01/01/2016, ABC, EUR, 185&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 27/01/2016, ABC, EUR, -25&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10/01/2016, DEF, GBP, -100&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 30/01/2016, DEF, GBP, 0&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;];&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FinalData:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD *,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; If(Previous(CLIENT) = CLIENT and CURRENCY = Previous(CURRENCY),&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; If(Previous(AMOUNT)&amp;lt;0,AMOUNT&amp;lt;0, 0), AMOUNT&amp;lt;0) as Flag&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Resident Data&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Order By CLIENT, CURRENCY, DATE;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;DROP Table Data;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2016 20:53:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Need-help-with-FirstSortedValue-Negative-count-upto-latest/m-p/1163287#M378980</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2016-05-17T20:53:11Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with FirstSortedValue - Negative count upto latest positive value</title>
      <link>https://community.qlik.com/t5/QlikView/Need-help-with-FirstSortedValue-Negative-count-upto-latest/m-p/1163288#M378981</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Agreed, Sunny&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2016 20:56:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Need-help-with-FirstSortedValue-Negative-count-upto-latest/m-p/1163288#M378981</guid>
      <dc:creator>Saravanan_Desingh</dc:creator>
      <dc:date>2016-05-17T20:56:07Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with FirstSortedValue - Negative count upto latest positive value</title>
      <link>https://community.qlik.com/t5/QlikView/Need-help-with-FirstSortedValue-Negative-count-upto-latest/m-p/1163289#M378982</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe this espression in a 2 dims chart&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Index(Concat(if(AMOUNT&amp;gt;=0,'+','-'), '', DATE), '+')-1&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="1.png" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/124851_1.png" style="height: auto; width: auto;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2016 21:23:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Need-help-with-FirstSortedValue-Negative-count-upto-latest/m-p/1163289#M378982</guid>
      <dc:creator>maxgro</dc:creator>
      <dc:date>2016-05-17T21:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with FirstSortedValue - Negative count upto latest positive value</title>
      <link>https://community.qlik.com/t5/QlikView/Need-help-with-FirstSortedValue-Negative-count-upto-latest/m-p/1163290#M378983</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Perfect. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 May 2016 08:19:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Need-help-with-FirstSortedValue-Negative-count-upto-latest/m-p/1163290#M378983</guid>
      <dc:creator>sanadm19</dc:creator>
      <dc:date>2016-05-18T08:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with FirstSortedValue - Negative count upto latest positive value</title>
      <link>https://community.qlik.com/t5/QlikView/Need-help-with-FirstSortedValue-Negative-count-upto-latest/m-p/1163291#M378984</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Sunny. Same answer, works great!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 May 2016 08:20:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Need-help-with-FirstSortedValue-Negative-count-upto-latest/m-p/1163291#M378984</guid>
      <dc:creator>sanadm19</dc:creator>
      <dc:date>2016-05-18T08:20:38Z</dc:date>
    </item>
  </channel>
</rss>

