<?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 - calculation in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803418#M65215</link>
    <description>&lt;P&gt;Where are you trying this? In KPI , or chart?&lt;/P&gt;&lt;P&gt;Also, in aggr(,&amp;lt;dimensions&amp;gt;), the second parameter is expected to be field name(s) and not an expression. If you can share an app with sample data and explain the expected output w.r.t that data,&amp;nbsp; it could be easier for us to help.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Apr 2021 09:04:48 GMT</pubDate>
    <dc:creator>tresB</dc:creator>
    <dc:date>2021-04-28T09:04:48Z</dc:date>
    <item>
      <title>Firstsortedvalue - calculation</title>
      <link>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803069#M65154</link>
      <description>&lt;P&gt;Hi -&lt;/P&gt;&lt;P&gt;I am trying to calculate the total number of quantity by the last date by state.&lt;/P&gt;&lt;P&gt;1. I created the following variable:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;vquantitylocation&lt;/P&gt;&lt;P&gt;=IF(LEN(Category)&amp;gt;0,location)&lt;/P&gt;&lt;P&gt;** This is created so that it removes any values from my data in which the Category is Null.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. I create the following master measure:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;firstsortedvalue(Aggr(sum(quantity),$(vquantitylocation) ,-date)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does not work - any thoughts ?? Thanks - Jerry&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2021 11:03:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803069#M65154</guid>
      <dc:creator>jerryr125</dc:creator>
      <dc:date>2021-04-27T11:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: Firstsortedvalue - calculation</title>
      <link>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803222#M65181</link>
      <description>&lt;P&gt;Hi -&amp;nbsp; also tried :&lt;/P&gt;&lt;P&gt;firstsortedvalue(Aggr(sum(quantity), date ,-date)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No luck - an assistance would be appreciated - Jerry&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2021 16:21:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803222#M65181</guid>
      <dc:creator>jerryr125</dc:creator>
      <dc:date>2021-04-27T16:21:45Z</dc:date>
    </item>
    <item>
      <title>Re: Firstsortedvalue - calculation</title>
      <link>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803411#M65211</link>
      <description>&lt;P&gt;Hi - I also tried the following :&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;firststortedvalue(quantity,-date)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Only works when you filter out on a specific location.&lt;/P&gt;&lt;P&gt;How can I get the function to work regardless of filtering on location or not ?&lt;/P&gt;&lt;P&gt;I also need to remove the locations which invalid :&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;vquantitylocation&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;IF(LEN(Category)&amp;gt;0,location)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any thoughts would be appreciated - stuck on this one - Jerry&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 08:32:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803411#M65211</guid>
      <dc:creator>jerryr125</dc:creator>
      <dc:date>2021-04-28T08:32:57Z</dc:date>
    </item>
    <item>
      <title>Re: Firstsortedvalue - calculation</title>
      <link>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803413#M65212</link>
      <description>&lt;P&gt;What is your dimension in chart?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 08:37:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803413#M65212</guid>
      <dc:creator>tresB</dc:creator>
      <dc:date>2021-04-28T08:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: Firstsortedvalue - calculation</title>
      <link>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803416#M65214</link>
      <description>&lt;P&gt;Hi tresesco -&lt;/P&gt;&lt;P&gt;I created a master measure to display in my tables, kpis, etc...&lt;/P&gt;&lt;P&gt;Master measure :&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;mmQuantityYTD&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Expression :&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;firstsortedvalue(quantity,-date)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Need to remove the invalid locations thus I tried to create a variable to do so and then add it to the firstsortedvalue function:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;vquantitylocation&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;IF(LEN(Category)&amp;gt;0,location)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this and no luck:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;firstsortedvalue(Aggr(sum(quantity),$(vquantitylocation) ,-date)&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 08:54:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803416#M65214</guid>
      <dc:creator>jerryr125</dc:creator>
      <dc:date>2021-04-28T08:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: Firstsortedvalue - calculation</title>
      <link>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803418#M65215</link>
      <description>&lt;P&gt;Where are you trying this? In KPI , or chart?&lt;/P&gt;&lt;P&gt;Also, in aggr(,&amp;lt;dimensions&amp;gt;), the second parameter is expected to be field name(s) and not an expression. If you can share an app with sample data and explain the expected output w.r.t that data,&amp;nbsp; it could be easier for us to help.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 09:04:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803418#M65215</guid>
      <dc:creator>tresB</dc:creator>
      <dc:date>2021-04-28T09:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: Firstsortedvalue - calculation</title>
      <link>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803481#M65226</link>
      <description>&lt;P&gt;Hi again Tresesco -&amp;nbsp;&lt;/P&gt;&lt;P&gt;Although I cannot share the application, here is what I can trying to achieve :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jerryr125_0-1619610333294.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/53879i9E4E73D46768D4DB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jerryr125_0-1619610333294.png" alt="jerryr125_0-1619610333294.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems as if the FirstSortedValue needs to remove the Locations with the Categories that are null.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thoughts&amp;nbsp; ? Thanks - Jerry&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 11:45:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803481#M65226</guid>
      <dc:creator>jerryr125</dc:creator>
      <dc:date>2021-04-28T11:45:50Z</dc:date>
    </item>
    <item>
      <title>Re: Firstsortedvalue - calculation</title>
      <link>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803502#M65229</link>
      <description>&lt;P&gt;Try like:&lt;/P&gt;&lt;P&gt;FirstSortedValue( {&amp;lt;Category={"=Len(Category)&amp;gt;0"}&amp;gt;}Aggr(Sum(quantitysold), Date, Location,Category), -Date)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tresesco_0-1619611782375.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/53888i8E6FBB25BA2D2F93/image-size/medium?v=v2&amp;amp;px=400" role="button" title="tresesco_0-1619611782375.png" alt="tresesco_0-1619611782375.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 12:09:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803502#M65229</guid>
      <dc:creator>tresB</dc:creator>
      <dc:date>2021-04-28T12:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: Firstsortedvalue - calculation</title>
      <link>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803515#M65232</link>
      <description>&lt;P&gt;Hi - thank you again for your help.&lt;/P&gt;&lt;P&gt;Getting very close.&lt;/P&gt;&lt;P&gt;This formula works if you select ONLY one location. When you select more than one location - no luck&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FirstSortedValue( Aggr(Sum(quantity),[date.autoCalendar.Date], location,[Category]), -[date.autoCalendar.Date])&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If I can take this formula and filter on the Categories were the LEN is &amp;gt;0 then we should be good...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This did not work (seems to not recognize the Category field with this syntax:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"=Len(Category)&amp;gt;0"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;FirstSortedValue( {&amp;lt;Category={"=Len(Category)&amp;gt;0"}&amp;gt;}Aggr(Sum(quantitysold), Date, Location,Category), -Date)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thoughts ? Jerry&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 12:46:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803515#M65232</guid>
      <dc:creator>jerryr125</dc:creator>
      <dc:date>2021-04-28T12:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: Firstsortedvalue - calculation</title>
      <link>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803679#M65257</link>
      <description>&lt;P&gt;Hi Tresesco - I sent you a private message with further information.&lt;/P&gt;&lt;P&gt;Thanks - Jerry&lt;/P&gt;</description>
      <pubDate>Thu, 29 Apr 2021 02:19:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803679#M65257</guid>
      <dc:creator>jerryr125</dc:creator>
      <dc:date>2021-04-29T02:19:10Z</dc:date>
    </item>
    <item>
      <title>Re: Firstsortedvalue - calculation</title>
      <link>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803712#M65260</link>
      <description>&lt;P&gt;I got your message and app. It seems the main issue is - granularity, at level you are trying to aggregate the measures. Instead of &lt;STRONG&gt;If(Sum(...&lt;/STRONG&gt; you should try with &lt;STRONG&gt;Sum(If..&lt;/STRONG&gt;&amp;nbsp;. I have made changes to first two KPIs you have in your app.&lt;/P&gt;&lt;P&gt;Try like:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;Sum(If(LEN(POPESTIMATE2020)&amp;gt;0,POPESTIMATE2020))&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;Sum({&amp;lt;[date.autoCalendar.Date]={'$(=Max([date.autoCalendar.Date]))'}&amp;gt;}people_vaccinated)&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Apr 2021 07:25:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803712#M65260</guid>
      <dc:creator>tresB</dc:creator>
      <dc:date>2021-04-29T07:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: Firstsortedvalue - calculation</title>
      <link>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803725#M65261</link>
      <description>&lt;P&gt;Hi - Thank you again so much for your help.&lt;/P&gt;&lt;P&gt;Almost there - I need to check to see if the state code has text (characters).&lt;/P&gt;&lt;P&gt;I tried this:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sum({&amp;lt;[date.autoCalendar.Date]={'$(=Max([date.autoCalendar.Date]))'},istext(left[State Code],1)&amp;gt;}people_vaccinated)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;No luck - thoughts&amp;nbsp; ?&lt;/P&gt;</description>
      <pubDate>Thu, 29 Apr 2021 08:12:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803725#M65261</guid>
      <dc:creator>jerryr125</dc:creator>
      <dc:date>2021-04-29T08:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: Firstsortedvalue - calculation</title>
      <link>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803800#M65271</link>
      <description>&lt;P&gt;Ok - still trying to make progress on this - almost there.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I changed the master measure to the following:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;IF((POPESTIMATE2020)&amp;gt;0,SUM({&amp;lt;[date.autoCalendar.Date]={'$(=Max([date.autoCalendar.Date]))'}&amp;gt;}people_fully_vaccinated),NUM('0'))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As a result:&lt;/P&gt;&lt;P&gt;This works&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jerryr125_0-1619697737672.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/53959i931FD23EC8DDB0DC/image-size/large?v=v2&amp;amp;px=999" role="button" title="jerryr125_0-1619697737672.png" alt="jerryr125_0-1619697737672.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Notice : American Samoa column for 'Fully Vaccinated YTD' is 0 - which is correct.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BUT now when&amp;nbsp; go to do view the KPI:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jerryr125_1-1619697885895.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/53961iF082ED3A8B5374AB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jerryr125_1-1619697885895.png" alt="jerryr125_1-1619697885895.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The KPI for Fully Vaccinated (YTD) it displays zero.&lt;/P&gt;&lt;P&gt;If I filter on one state it works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any thoughts ? Jerry&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Apr 2021 12:06:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803800#M65271</guid>
      <dc:creator>jerryr125</dc:creator>
      <dc:date>2021-04-29T12:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: Firstsortedvalue - calculation</title>
      <link>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803820#M65275</link>
      <description>&lt;P&gt;That is because, you are making the same mistake, using if(sum( .... structure instead of sum(if(... (I suggested above).&amp;nbsp;&lt;/P&gt;&lt;P&gt;Expression to be tried:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;SUM({&amp;lt;POPESTIMATE2020={"&amp;gt;0"},[date.autoCalendar.Date]={'$(=Max([date.autoCalendar.Date]))'}&amp;gt;}people_fully_vaccinated)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;Please close the thread by liking and/or marking correct answer. That would help others as well.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Apr 2021 12:43:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803820#M65275</guid>
      <dc:creator>tresB</dc:creator>
      <dc:date>2021-04-29T12:43:16Z</dc:date>
    </item>
    <item>
      <title>Re: Firstsortedvalue - calculation</title>
      <link>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803831#M65279</link>
      <description>&lt;P&gt;Thank you again so much for your help and dedication&lt;/P&gt;&lt;P&gt;Yes, this is correct :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;SUM({&amp;lt;POPESTIMATE2020={"&amp;gt;0"},[date.autoCalendar.Date]={'$(=Max([date.autoCalendar.Date]))'}&amp;gt;}people_fully_vaccinated)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Apr 2021 13:15:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Firstsortedvalue-calculation/m-p/1803831#M65279</guid>
      <dc:creator>jerryr125</dc:creator>
      <dc:date>2021-04-29T13:15:21Z</dc:date>
    </item>
  </channel>
</rss>

