<?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: How to use Rank in a KPI? in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/How-to-use-Rank-in-a-KPI/m-p/2494498#M102451</link>
    <description>&lt;P&gt;Hi Matheus,&lt;/P&gt;
&lt;P&gt;That worked great. Thank you very much.&lt;/P&gt;</description>
    <pubDate>Mon, 25 Nov 2024 18:44:22 GMT</pubDate>
    <dc:creator>mikegrattan</dc:creator>
    <dc:date>2024-11-25T18:44:22Z</dc:date>
    <item>
      <title>How to use Rank in a KPI?</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-use-Rank-in-a-KPI/m-p/2494470#M102441</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I'm trying to do a few things in a KPI:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Show a quantity for a commodity that has been flagged as "aged" (Flag_Aged = 1)&lt;/LI&gt;
&lt;LI&gt;Limit the quantity shown, so it's only for the specified rank (vRank = 1 for example)&lt;/LI&gt;
&lt;LI&gt;Show the name of the commodity in the label&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;This expression works for ranking the commodity by the amount that is flagged as "Aged" - it is the definition of the variable "vRank":&lt;/P&gt;
&lt;P&gt;rank(Sum({&amp;lt;Cooler={'SAL','YUM'},Flag_Aged={1}&amp;gt;}Quantity))&lt;/P&gt;
&lt;P&gt;The expression the KPI is:&amp;nbsp;&amp;nbsp;Sum({&amp;lt;vRank={1},Cooler={'SAL','YUM'},Flag_Aged={1}&amp;gt;} Quantity)&lt;/P&gt;
&lt;P&gt;However, the result is not being limited to the Commodity that is ranked as 1.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please advise. Thank you.&lt;/P&gt;
&lt;P&gt;Screenshot shows KPI result and table of top 10 commodities, using the Fixed Number limitation on Commodity. The expression for the Quantity Aged field is:&amp;nbsp;Sum({&amp;lt;Flag_Aged={1},Cooler={'SAL','YUM'}&amp;gt;}Quantity). In this example, I'm trying to get the KPI to show the Quantity Aged for commodity ROM since it is ranked #1.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mikegrattan_0-1732551582180.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/174821iB8B72BC02E264EFB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mikegrattan_0-1732551582180.png" alt="mikegrattan_0-1732551582180.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2024 16:20:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-use-Rank-in-a-KPI/m-p/2494470#M102441</guid>
      <dc:creator>mikegrattan</dc:creator>
      <dc:date>2024-11-25T16:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Rank in a KPI?</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-use-Rank-in-a-KPI/m-p/2494477#M102442</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Maybe this, inserting the rank in your set analysis:&lt;BR /&gt;&lt;BR /&gt;sum({&amp;lt;Commodity={&lt;STRONG&gt;"rank(Sum({&amp;lt;Cooler={'SAL','YUM'},Flag_Aged={1}&amp;gt;}Quantity))=1"&lt;/STRONG&gt;}&amp;gt;}Quantity)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;- Regards, Matheus&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2024 16:57:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-use-Rank-in-a-KPI/m-p/2494477#M102442</guid>
      <dc:creator>MatheusC</dc:creator>
      <dc:date>2024-11-25T16:57:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Rank in a KPI?</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-use-Rank-in-a-KPI/m-p/2494483#M102443</link>
      <description>&lt;P&gt;Hi Matheus,&lt;/P&gt;
&lt;P&gt;I'm getting a 0 as the result of that expression. I updated the data load script to exclude various Coolers and Commodities, so the set expression can now be simplified to&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;sum({&amp;lt;Commodity={&lt;/SPAN&gt;&lt;STRONG&gt;"rank(Sum({&amp;lt;Flag_Aged={1}&amp;gt;}Quantity))=1"&lt;/STRONG&gt;&lt;SPAN&gt;}&amp;gt;}Quantity). &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I also tried&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Sum({&amp;lt;Commodity={"rank(Sum({&amp;lt;Flag_Aged={1}&amp;gt;}Quantity))=1"},Flag_Aged={1}&amp;gt;}Quantity)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;but that results in a 0 value as well.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2024 17:17:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-use-Rank-in-a-KPI/m-p/2494483#M102443</guid>
      <dc:creator>mikegrattan</dc:creator>
      <dc:date>2024-11-25T17:17:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Rank in a KPI?</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-use-Rank-in-a-KPI/m-p/2494485#M102445</link>
      <description>&lt;P&gt;&lt;SPAN&gt;My mistake, that's all I missed &lt;STRONG&gt;=&lt;BR /&gt;&lt;BR /&gt;sum({&amp;lt;Commodity={"&lt;FONT color="#FF0000"&gt;=&lt;/FONT&gt;rank(Sum({&amp;lt;Flag_Aged={1}&amp;gt;}Quantity))=1"}&amp;gt;}Quantity)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2024 17:36:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-use-Rank-in-a-KPI/m-p/2494485#M102445</guid>
      <dc:creator>MatheusC</dc:creator>
      <dc:date>2024-11-25T17:36:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Rank in a KPI?</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-use-Rank-in-a-KPI/m-p/2494487#M102446</link>
      <description>&lt;P&gt;Perfect. Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2024 17:38:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-use-Rank-in-a-KPI/m-p/2494487#M102446</guid>
      <dc:creator>mikegrattan</dc:creator>
      <dc:date>2024-11-25T17:38:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Rank in a KPI?</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-use-Rank-in-a-KPI/m-p/2494488#M102447</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not Sure but you can't call a variable (vRank) in a set analysis : it must be a dimension&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So try&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IF(&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;rank(Sum({&amp;lt;Cooler={'SAL','YUM'},Flag_Aged={1}&amp;gt;}Quantity)) = 1 ,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Sum({&amp;lt;Cooler={'SAL','YUM'},Flag_Aged={1}&amp;gt;}Quantity), 0&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;and may be to get the commodities :&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;firstsortedvalue (&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;commodities ,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;IF(&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;rank(Sum({&amp;lt;Cooler={'SAL','YUM'},Flag_Aged={1}&amp;gt;}Quantity)) = 1 ,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Sum({&amp;lt;Cooler={'SAL','YUM'},Flag_Aged={1}&amp;gt;}Quantity), 0&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2024 17:39:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-use-Rank-in-a-KPI/m-p/2494488#M102447</guid>
      <dc:creator>brunobertels</dc:creator>
      <dc:date>2024-11-25T17:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Rank in a KPI?</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-use-Rank-in-a-KPI/m-p/2494489#M102448</link>
      <description>&lt;P&gt;Oh, almost forgot. How do I get the label of the KPI to show the Commodity?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2024 17:39:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-use-Rank-in-a-KPI/m-p/2494489#M102448</guid>
      <dc:creator>mikegrattan</dc:creator>
      <dc:date>2024-11-25T17:39:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Rank in a KPI?</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-use-Rank-in-a-KPI/m-p/2494494#M102449</link>
      <description>&lt;P&gt;Hi Bruno,&lt;/P&gt;
&lt;P&gt;I tried your expression using FirstSortedValue, but it's throwing an error about a nested aggregation. I tried searching for that error and found several posts in Qlik Community with no solution. Not sure what to do at this point.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2024 18:27:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-use-Rank-in-a-KPI/m-p/2494494#M102449</guid>
      <dc:creator>mikegrattan</dc:creator>
      <dc:date>2024-11-25T18:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Rank in a KPI?</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-use-Rank-in-a-KPI/m-p/2494495#M102450</link>
      <description>&lt;P&gt;for the label, see like this:&lt;BR /&gt;&lt;BR /&gt;=&lt;STRONG&gt;only&lt;/STRONG&gt;({&amp;lt;Commodity= {"=Rank(sum({&amp;lt;Flag_Aged={1}&amp;gt;}Quantity))=1"}&amp;gt;} Commodity)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2024 18:35:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-use-Rank-in-a-KPI/m-p/2494495#M102450</guid>
      <dc:creator>MatheusC</dc:creator>
      <dc:date>2024-11-25T18:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Rank in a KPI?</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-use-Rank-in-a-KPI/m-p/2494498#M102451</link>
      <description>&lt;P&gt;Hi Matheus,&lt;/P&gt;
&lt;P&gt;That worked great. Thank you very much.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2024 18:44:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-use-Rank-in-a-KPI/m-p/2494498#M102451</guid>
      <dc:creator>mikegrattan</dc:creator>
      <dc:date>2024-11-25T18:44:22Z</dc:date>
    </item>
  </channel>
</rss>

