<?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 in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Firstsortedvalue/m-p/467920#M174740</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I wrote this incorrectly: &lt;/P&gt;&lt;P&gt;WRONG:&lt;/P&gt;&lt;P&gt;"Need help figuring out why this doesnt aggregate correctly.&amp;nbsp; Trying to display, in a text box, the current year growth of a partner (VAR Reporting Name) based on this year to date as compared to the same year last year thru the SAME date last year." &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"Need to display the largest growth rate of all the growth rates for [IDC Vertical Market].&amp;nbsp; I need to display the name of the [IDC Vertical Market] with the highest growth rate in another text box."&amp;nbsp; I am doing the same for the Top End Customer, Top State, Top Brand, etc....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 Nov 2012 15:41:37 GMT</pubDate>
    <dc:creator />
    <dc:date>2012-11-27T15:41:37Z</dc:date>
    <item>
      <title>Firstsortedvalue</title>
      <link>https://community.qlik.com/t5/QlikView/Firstsortedvalue/m-p/467917#M174737</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Need help figuring out why this doesnt aggregate correctly.&amp;nbsp; Trying to display, in a text box, the current year growth of a partner (VAR Reporting Name) based on this year to date as compared to the same year last year thru the SAME date last year.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;FirstSortedValue&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;(&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;num&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;aggr&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;(&lt;BR /&gt;&lt;BR /&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;({&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[Calendar Year]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;=,&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[VAR Reporting Name]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;= {'$(vSolutionProviderName)'}&amp;gt;} &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; (&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;InYear&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; (&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[Invoice Date]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;, &lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style=": ; color: #808080; font-size: 10pt;"&gt;vMaxInvDateFiltered&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt;"&gt;, 0) &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; (&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[Invoice Date]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;) &amp;lt;= &lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style=": ; color: #808080; font-size: 10pt;"&gt;vMaxInvDateFiltered&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt;"&gt; , &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[Total Sales]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;)) /&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;({&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[Calendar Year]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;=,&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[VAR Reporting Name]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;= {'$(vSolutionProviderName)'}&amp;gt;}&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; (&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;InYear&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; (&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[Invoice Date]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;, &lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style=": ; color: #808080; font-size: 10pt;"&gt;vMaxInvDateFiltered&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt;"&gt;, -1) &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; (&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[Invoice Date]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;) &amp;lt;= &lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style=": ; color: #808080; font-size: 10pt;"&gt;vMaxInvDateFiltered&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt;"&gt;-365, &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[Total Sales]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;))&lt;BR /&gt;&lt;BR /&gt;),&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[IDC Vertical Market]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;),'#,##0.0%')&lt;BR /&gt;&lt;BR /&gt;,&lt;BR /&gt;&lt;BR /&gt;-&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;aggr&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;(&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;({&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[Calendar Year]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;=,&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[VAR Reporting Name]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;= {'$(vSolutionProviderName)'}&amp;gt;} &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; (&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;InYear&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; (&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[Invoice Date]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;, &lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style=": ; color: #808080; font-size: 10pt;"&gt;vMaxInvDateFiltered&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt;"&gt;, 0) &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; (&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[Invoice Date]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;) &amp;lt;= &lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style=": ; color: #808080; font-size: 10pt;"&gt;vMaxInvDateFiltered&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt;"&gt; , &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[Total Sales]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;)) /&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;({&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[Calendar Year]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;=,&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[VAR Reporting Name]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;= {'$(vSolutionProviderName)'}&amp;gt;}&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; (&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;InYear&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; (&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[Invoice Date]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;, &lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style=": ; color: #808080; font-size: 10pt;"&gt;vMaxInvDateFiltered&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt;"&gt;, -1) &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt; (&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[Invoice Date]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;) &amp;lt;= &lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style=": ; color: #808080; font-size: 10pt;"&gt;vMaxInvDateFiltered&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt;"&gt;-365, &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[Total Sales]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;))&lt;BR /&gt;&lt;BR /&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;[IDC Vertical Market]&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;)) &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Nov 2012 21:53:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Firstsortedvalue/m-p/467917#M174737</guid>
      <dc:creator />
      <dc:date>2012-11-26T21:53:53Z</dc:date>
    </item>
    <item>
      <title>Re: Firstsortedvalue</title>
      <link>https://community.qlik.com/t5/QlikView/Firstsortedvalue/m-p/467918#M174738</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not exactly sure why you're using firstsortedvalue--that function does something totally different than what you're trying to do. The easiest way to do what you want is to create a new variable:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vLastYearYTD = addyears(vMaxInvDateFiltered,-1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then use this new variable in your expression as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(sum({&amp;lt;[Calendar Year]=,[VAR Reporting Name]= {'$(vSolutionProviderName)'},[Invoice Date]={"&amp;lt;=$(vMaxInvDateFiltered)"}&amp;gt;} [Total Sales])&lt;/P&gt;&lt;P&gt;/&lt;/P&gt;&lt;P&gt;(sum({&amp;lt;[Calendar Year]=,[VAR Reporting Name]= {'$(vSolutionProviderName)'},[Invoice Date]={"&amp;lt;=$(vLastYearYTD)"}&amp;gt;} [Total Sales])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't think you need to aggr() unless there are some business rules I am not aware of. If you need to keep the aggr, you need to either surround it by an aggregation expression or make sure it return a single value (because it's in a text box).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vlad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Nov 2012 04:27:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Firstsortedvalue/m-p/467918#M174738</guid>
      <dc:creator>vgutkovsky</dc:creator>
      <dc:date>2012-11-27T04:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: Firstsortedvalue</title>
      <link>https://community.qlik.com/t5/QlikView/Firstsortedvalue/m-p/467919#M174739</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank&lt;BR /&gt;you Vlad&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am&lt;BR /&gt;aggr() because i want the name of the customer and the value&amp;nbsp; for the customer with the top sales growth for the given category in each text box.&amp;nbsp; So if Customer ABC has the highest YOY growth based on the same time this year compared to the same time last year, over&amp;nbsp; all customers for the given Solution Provider , I want to display that name in one text box and the value of the growth in the other text box.&amp;nbsp; Thus, FirstSOrtedValue() function.&amp;nbsp; DOes that help?&amp;nbsp; SOrry I wasnt clear.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It works for the top sales $ value, it is the growth formula that is not working correctly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: &amp;amp;quot;Times New Roman&amp;amp;quot;,&amp;amp;quot;serif&amp;amp;quot;; font-size: 12pt; mso-fareast-font-family: &amp;amp;quot;Times New Roman&amp;amp;quot;; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;"&gt;In this case I want the customer name for that&lt;BR /&gt;customer with the highest growth&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Nov 2012 15:37:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Firstsortedvalue/m-p/467919#M174739</guid>
      <dc:creator />
      <dc:date>2012-11-27T15:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: Firstsortedvalue</title>
      <link>https://community.qlik.com/t5/QlikView/Firstsortedvalue/m-p/467920#M174740</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I wrote this incorrectly: &lt;/P&gt;&lt;P&gt;WRONG:&lt;/P&gt;&lt;P&gt;"Need help figuring out why this doesnt aggregate correctly.&amp;nbsp; Trying to display, in a text box, the current year growth of a partner (VAR Reporting Name) based on this year to date as compared to the same year last year thru the SAME date last year." &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"Need to display the largest growth rate of all the growth rates for [IDC Vertical Market].&amp;nbsp; I need to display the name of the [IDC Vertical Market] with the highest growth rate in another text box."&amp;nbsp; I am doing the same for the Top End Customer, Top State, Top Brand, etc....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Nov 2012 15:41:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Firstsortedvalue/m-p/467920#M174740</guid>
      <dc:creator />
      <dc:date>2012-11-27T15:41:37Z</dc:date>
    </item>
    <item>
      <title>Re: Firstsortedvalue</title>
      <link>https://community.qlik.com/t5/QlikView/Firstsortedvalue/m-p/467921#M174741</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;second paragraph is correct.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Nov 2012 15:41:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Firstsortedvalue/m-p/467921#M174741</guid>
      <dc:creator />
      <dc:date>2012-11-27T15:41:56Z</dc:date>
    </item>
    <item>
      <title>Re: Firstsortedvalue</title>
      <link>https://community.qlik.com/t5/QlikView/Firstsortedvalue/m-p/467922#M174742</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this to display the highest rate (using the variable I created above):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Create a variable called &lt;STRONG&gt;vMaxMarketRate&lt;/STRONG&gt;:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=max(aggr(&lt;/P&gt;&lt;P&gt;(sum({&amp;lt;[Calendar Year]=,[VAR Reporting Name]= {'$(vSolutionProviderName)'},[Invoice Date]={"&amp;lt;=$(vMaxInvDateFiltered)"}&amp;gt;} [Total Sales])&lt;/P&gt;&lt;P&gt;/&lt;/P&gt;&lt;P&gt;(sum({&amp;lt;[Calendar Year]=,[VAR Reporting Name]= {'$(vSolutionProviderName)'},[Invoice Date]={"&amp;lt;=$(vLastYearYTD)"}&amp;gt;} [Total Sales])&lt;/P&gt;&lt;P&gt;,[IDC Vertical Market]))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can just enter vMaxMarketRate into the text box. The following should display the name of the market with the highest rate:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;maxstring(aggr(&lt;/P&gt;&lt;P&gt;if(&lt;/P&gt;&lt;P&gt;(sum({&amp;lt;[Calendar Year]=,[VAR Reporting Name]= {'$(vSolutionProviderName)'},[Invoice Date]={"&amp;lt;=$(vMaxInvDateFiltered)"}&amp;gt;} [Total Sales])&lt;/P&gt;&lt;P&gt;/&lt;/P&gt;&lt;P&gt;(sum({&amp;lt;[Calendar Year]=,[VAR Reporting Name]= {'$(vSolutionProviderName)'},[Invoice Date]={"&amp;lt;=$(vLastYearYTD)"}&amp;gt;} [Total Sales])=vMaxMarketRate,[IDC Vertical Market])&lt;/P&gt;&lt;P&gt;,[IDC Vertical Market]))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Nov 2012 18:55:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Firstsortedvalue/m-p/467922#M174742</guid>
      <dc:creator>vgutkovsky</dc:creator>
      <dc:date>2012-11-27T18:55:38Z</dc:date>
    </item>
  </channel>
</rss>

