<?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 Rank Formula in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/FirstSortedValue-Rank-Formula/m-p/1840890#M69651</link>
    <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/22949"&gt;@tresB&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I get it. Great! Thanks for the clarification!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 01 Oct 2021 12:55:45 GMT</pubDate>
    <dc:creator>Digvijay_Singh</dc:creator>
    <dc:date>2021-10-01T12:55:45Z</dc:date>
    <item>
      <title>FirstSortedValue Rank Formula</title>
      <link>https://community.qlik.com/t5/App-Development/FirstSortedValue-Rank-Formula/m-p/1840009#M69540</link>
      <description>&lt;P&gt;=FirstSortedValue(&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;lt;[MHS_SP.Abandoned]={'1'}, [MHS_SP.TimeBeforeAbandoned]={"&amp;gt;=20"}&amp;gt;}&lt;BR /&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; [MHS_SP.TimeBeforeAbandoned],&lt;BR /&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; -([MHS_SP.TimeBeforeAbandoned] + ([MHS_SP.SessionStartAestTime]/1E10)),&lt;BR /&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; &lt;STRONG&gt;24000&lt;/STRONG&gt;)&lt;/P&gt;&lt;P&gt;So I am having trouble with the last variable 'Rank' (24000). The above runs run and gives the correct answer. However, I want to convert the Rank value to a formula. The below replacement formula tested returns the same value (24000), but as soon as I drop it into the FirstSortedValue I get NULL.&lt;/P&gt;&lt;P&gt;=FirstSortedValue(&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;lt;[MHS_SP.Abandoned]={'1'}, [MHS_SP.TimeBeforeAbandoned]={"&amp;gt;=20"}&amp;gt;}&lt;BR /&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; [MHS_SP.TimeBeforeAbandoned],&lt;BR /&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; -([MHS_SP.TimeBeforeAbandoned] + ([MHS_SP.SessionStartAestTime]/1E10)),&lt;BR /&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; &lt;STRONG&gt;round(Sum([MHS_SP.Abandoned]) * 0.8&lt;/STRONG&gt;) )&lt;/P&gt;&lt;P&gt;In fact, it has nothing to do specifically with the above formula. Any metric formula returns NULL, even if I use &lt;STRONG&gt;COUNT(1)&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;=FirstSortedValue(&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;lt;[MHS_SP.Abandoned]={'1'}, [MHS_SP.TimeBeforeAbandoned]={"&amp;gt;=20"}&amp;gt;}&lt;BR /&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; [MHS_SP.TimeBeforeAbandoned],&lt;BR /&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; -([MHS_SP.TimeBeforeAbandoned] + ([MHS_SP.SessionStartAestTime]/1E10)),&lt;BR /&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; &lt;STRONG&gt;count(1)&lt;/STRONG&gt; )&lt;/P&gt;&lt;P&gt;As soon as I convert it to &lt;STRONG&gt;1&lt;/STRONG&gt; - it works.&lt;/P&gt;&lt;P&gt;Thoughts?&lt;/P&gt;&lt;P&gt;Andrew&lt;/P&gt;</description>
      <pubDate>Wed, 29 Sep 2021 08:44:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/FirstSortedValue-Rank-Formula/m-p/1840009#M69540</guid>
      <dc:creator>andrewc</dc:creator>
      <dc:date>2021-09-29T08:44:58Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue Rank Formula</title>
      <link>https://community.qlik.com/t5/App-Development/FirstSortedValue-Rank-Formula/m-p/1840727#M69622</link>
      <description>&lt;P&gt;I just tried few things on the 3rd parameter, looks like firstsortedvalue expect 3rd parameter to have numeric value before it starts evaluating it, so may be you try enclosing your 3rd parameter inside $(=).&lt;/P&gt;&lt;P&gt;firstsortedvalue (Product, UnitPrice, $(=Count(1))) worked so may be you try on similar lines..&lt;/P&gt;</description>
      <pubDate>Fri, 01 Oct 2021 03:24:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/FirstSortedValue-Rank-Formula/m-p/1840727#M69622</guid>
      <dc:creator>Digvijay_Singh</dc:creator>
      <dc:date>2021-10-01T03:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue Rank Formula</title>
      <link>https://community.qlik.com/t5/App-Development/FirstSortedValue-Rank-Formula/m-p/1840736#M69623</link>
      <description>&lt;P&gt;I would interpret this little differently.&amp;nbsp;&lt;/P&gt;&lt;P&gt;3rd parameter expects numeric value that's true - but it doesn't have to be a non-expression. It has to be an expression that returns single number. The issue with your expression is the &lt;STRONG&gt;scope of aggregation&amp;nbsp;&lt;/STRONG&gt;and that is actually producing multiple numbers. And you can't have multiple ranks passed in here as 3rd parameter.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you put &lt;EM&gt;Count(&lt;STRONG&gt;total&lt;/STRONG&gt; ...) or Sum(total...)&lt;/EM&gt;&amp;nbsp;you would see it is working - because it returns &lt;STRONG&gt;single value&lt;/STRONG&gt;. $(=..) solution would work because it gets evaluated outside your aggregation scope of the expression and generates one number.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this makes sense.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Oct 2021 12:58:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/FirstSortedValue-Rank-Formula/m-p/1840736#M69623</guid>
      <dc:creator>tresB</dc:creator>
      <dc:date>2021-10-01T12:58:09Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue Rank Formula</title>
      <link>https://community.qlik.com/t5/App-Development/FirstSortedValue-Rank-Formula/m-p/1840859#M69642</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/22949"&gt;@tresB&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks, missed looking from that angle, but I was wondering why Count(1) doesn't work, if I put that in a text box it shows value 1, generally I take it as resulting single value if something shows up in text box.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Oct 2021 12:00:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/FirstSortedValue-Rank-Formula/m-p/1840859#M69642</guid>
      <dc:creator>Digvijay_Singh</dc:creator>
      <dc:date>2021-10-01T12:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue Rank Formula</title>
      <link>https://community.qlik.com/t5/App-Development/FirstSortedValue-Rank-Formula/m-p/1840870#M69647</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/48860"&gt;@Digvijay_Singh&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Let us put that our context is 'expression in KPI object/text box; no chart with dimension'.&lt;/P&gt;&lt;P&gt;Had this Count(...) been used in other function like, Max( Sales, Count(...)) - it would work, because, as you said count(...) in this case would return single value. However, I would assume that FirstSortedValue() is unlike all other aggregation functions (I really don't know how &lt;EM&gt;under-the-hood&lt;/EM&gt; algorithm is working - it is just my logical inference you can say). FirstSortedValue() has a dimension mentioned as a parameter against which the the ranking has to happen and based on the sorted result - it gives the output. The&amp;nbsp; 2nd parameter we pass in this function is nothing but a kind of virtual aggregation dimension.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My bet is that - if you are putting an expression as a third parameter for rank position - it is going to be evaluated based on the same virtual dimension -&amp;nbsp; and that is the reason it generates possible multiple values.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;I.e. -&amp;nbsp;&amp;nbsp;scope of function evaluation is the key here.&lt;/P&gt;&lt;P&gt;Update : I was playing around with it a little more, and seems that actually both the&amp;nbsp;1st &amp;amp; 2nd parameters play role in virtual aggregation.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Oct 2021 13:15:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/FirstSortedValue-Rank-Formula/m-p/1840870#M69647</guid>
      <dc:creator>tresB</dc:creator>
      <dc:date>2021-10-01T13:15:38Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue Rank Formula</title>
      <link>https://community.qlik.com/t5/App-Development/FirstSortedValue-Rank-Formula/m-p/1840890#M69651</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/22949"&gt;@tresB&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I get it. Great! Thanks for the clarification!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Oct 2021 12:55:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/FirstSortedValue-Rank-Formula/m-p/1840890#M69651</guid>
      <dc:creator>Digvijay_Singh</dc:creator>
      <dc:date>2021-10-01T12:55:45Z</dc:date>
    </item>
  </channel>
</rss>

