<?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: rangemax function - 2nd highest value in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/rangemax-function-2nd-highest-value/m-p/445541#M485557</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is how I did it. For reference, TR, A, STL, BLK are all fields. ASSTS, REBS, STLS, BLKS are just text strings used to form a text string like "4 REBS, 3 ASSTS".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So basically the way it works is it looks to see if TR is the largest. If it is, then it ignores TR because I don't want the largest of the 4, I want the 2nd largest. So now that it knows TR is the largest, it finds the largest between the remaining 3 stats with nested rangemax and if/then functions. So that's the first section of the expression. The next section looks to see if A is the largest, and if it is, finds the largest of TR, STL, BLK. So it runs through all the possibilities. As I said, you could do this with more than 4 stats but each time you add one the expression grows exponentially larger. The full expression is below. Hope that's helpful!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if(rangemax(TR+.1,A+.01,STL+.001,BLK+.0001)=TR+.1,if(rangemax(A+.01,STL+.001,BLK+.0001)=A+.01,if(A=0,'',if(A=1,', ASST',', '&amp;amp;A&amp;amp;' ASSTS')),if(rangemax(A+.01,STL+.001,BLK+.0001)=STL+.001,if(STL=0,'',if(STL=1,', STL',', '&amp;amp;STL&amp;amp;' STLS')),if(BLK=0,'',if(BLK=1,', BLK',', '&amp;amp;BLK&amp;amp;' BLKS')))),&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if(rangemax(TR+.1,A+.01,STL+.001,BLK+.0001)=A+.01,if(rangemax(TR+.1,STL+.001,BLK+.0001)=TR+.1,if(TR=0,'',if(TR=1,', REB',', '&amp;amp;TR&amp;amp;' REBS')),if(rangemax(TR+.1,STL+.001,BLK+.0001)=STL+.001,if(STL=0,'',if(STL=1,', STL',', '&amp;amp;STL&amp;amp;' STLS')),if(BLK=0,'',if(BLK=1,', BLK',', '&amp;amp;BLK&amp;amp;' BLKS')))),&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if(rangemax(TR+.1,A+.01,STL+.001,BLK+.0001)=STL+.001,if(rangemax(TR+.1,A+.01,BLK+.0001)=TR+.1,if(TR=0,'',if(TR=1,', REB',', '&amp;amp;TR&amp;amp;' REBS')),if(rangemax(TR+.1,A+.01,BLK+.0001)=A+.01,if(A=0,'',if(A=1,', ASST',', '&amp;amp;A&amp;amp;' ASSTS')),if(BLK=0,'',if(BLK=1,', BLK',', '&amp;amp;BLK&amp;amp;' BLKS')))),&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if(rangemax(TR+.1,A+.01,STL+.001,BLK+.0001)=BLK+.0001,if(rangemax(TR+.1,A+.01,STL+.001)=TR+.1,if(TR=0,'',if(TR=1,', REB',', '&amp;amp;TR&amp;amp;' REBS')),if(rangemax(TR+.1,A+.01,STL+.001)=A+.01,if(A=0,'',if(A=1,', ASST',', '&amp;amp;A&amp;amp;' ASSTS')),if(STL=0,'',if(STL=1,', STL',', '&amp;amp;STL&amp;amp;' STLS')))))&lt;/P&gt;&lt;P&gt;)))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 13 Oct 2015 14:29:47 GMT</pubDate>
    <dc:creator />
    <dc:date>2015-10-13T14:29:47Z</dc:date>
    <item>
      <title>rangemax function - 2nd highest value</title>
      <link>https://community.qlik.com/t5/QlikView/rangemax-function-2nd-highest-value/m-p/445537#M485553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to sort a bunch of fields to create a stat-line of sorts from a basketball boxscore. Basically what I want it to do is return the best and 2nd best stat from a range of 4 stats. So if the 4 stats are PTS, REB, AST, STL, my formula to get the best stat would be: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rangemax(PTS+.1,REB+.01,AST+.001,STL+.0001) --&amp;gt; the .1, .01 etc. is there to make sure I never have the same value in multiple fields&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I need now is a formula to return the 2nd best stat. There must be a way, either with this function or another similar function, to put in all the fields and put ", 2" at the end as I would with a max function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Apr 2013 15:04:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/rangemax-function-2nd-highest-value/m-p/445537#M485553</guid>
      <dc:creator />
      <dc:date>2013-04-11T15:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: rangemax function - 2nd highest value</title>
      <link>https://community.qlik.com/t5/QlikView/rangemax-function-2nd-highest-value/m-p/445538#M485554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am looking for such function too...Has there been a solution? Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Oct 2015 13:44:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/rangemax-function-2nd-highest-value/m-p/445538#M485554</guid>
      <dc:creator />
      <dc:date>2015-10-13T13:44:39Z</dc:date>
    </item>
    <item>
      <title>Re: rangemax function - 2nd highest value</title>
      <link>https://community.qlik.com/t5/QlikView/rangemax-function-2nd-highest-value/m-p/445539#M485555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Didn't find a function that would do it, but I managed to get it to work by nesting rangemax functions. It works well for what I'm doing, taking the 2nd best of 4 stats, but if the nesting would increase exponentially with each additional stat. But it's great for 2-4 stats. I can send my expression if you'd find it helpful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Oct 2015 14:10:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/rangemax-function-2nd-highest-value/m-p/445539#M485555</guid>
      <dc:creator />
      <dc:date>2015-10-13T14:10:43Z</dc:date>
    </item>
    <item>
      <title>Re: rangemax function - 2nd highest value</title>
      <link>https://community.qlik.com/t5/QlikView/rangemax-function-2nd-highest-value/m-p/445540#M485556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes thank you very much! That would be very helpful! I have 4 expressions to compare as well. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Oct 2015 14:18:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/rangemax-function-2nd-highest-value/m-p/445540#M485556</guid>
      <dc:creator />
      <dc:date>2015-10-13T14:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: rangemax function - 2nd highest value</title>
      <link>https://community.qlik.com/t5/QlikView/rangemax-function-2nd-highest-value/m-p/445541#M485557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is how I did it. For reference, TR, A, STL, BLK are all fields. ASSTS, REBS, STLS, BLKS are just text strings used to form a text string like "4 REBS, 3 ASSTS".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So basically the way it works is it looks to see if TR is the largest. If it is, then it ignores TR because I don't want the largest of the 4, I want the 2nd largest. So now that it knows TR is the largest, it finds the largest between the remaining 3 stats with nested rangemax and if/then functions. So that's the first section of the expression. The next section looks to see if A is the largest, and if it is, finds the largest of TR, STL, BLK. So it runs through all the possibilities. As I said, you could do this with more than 4 stats but each time you add one the expression grows exponentially larger. The full expression is below. Hope that's helpful!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if(rangemax(TR+.1,A+.01,STL+.001,BLK+.0001)=TR+.1,if(rangemax(A+.01,STL+.001,BLK+.0001)=A+.01,if(A=0,'',if(A=1,', ASST',', '&amp;amp;A&amp;amp;' ASSTS')),if(rangemax(A+.01,STL+.001,BLK+.0001)=STL+.001,if(STL=0,'',if(STL=1,', STL',', '&amp;amp;STL&amp;amp;' STLS')),if(BLK=0,'',if(BLK=1,', BLK',', '&amp;amp;BLK&amp;amp;' BLKS')))),&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if(rangemax(TR+.1,A+.01,STL+.001,BLK+.0001)=A+.01,if(rangemax(TR+.1,STL+.001,BLK+.0001)=TR+.1,if(TR=0,'',if(TR=1,', REB',', '&amp;amp;TR&amp;amp;' REBS')),if(rangemax(TR+.1,STL+.001,BLK+.0001)=STL+.001,if(STL=0,'',if(STL=1,', STL',', '&amp;amp;STL&amp;amp;' STLS')),if(BLK=0,'',if(BLK=1,', BLK',', '&amp;amp;BLK&amp;amp;' BLKS')))),&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if(rangemax(TR+.1,A+.01,STL+.001,BLK+.0001)=STL+.001,if(rangemax(TR+.1,A+.01,BLK+.0001)=TR+.1,if(TR=0,'',if(TR=1,', REB',', '&amp;amp;TR&amp;amp;' REBS')),if(rangemax(TR+.1,A+.01,BLK+.0001)=A+.01,if(A=0,'',if(A=1,', ASST',', '&amp;amp;A&amp;amp;' ASSTS')),if(BLK=0,'',if(BLK=1,', BLK',', '&amp;amp;BLK&amp;amp;' BLKS')))),&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if(rangemax(TR+.1,A+.01,STL+.001,BLK+.0001)=BLK+.0001,if(rangemax(TR+.1,A+.01,STL+.001)=TR+.1,if(TR=0,'',if(TR=1,', REB',', '&amp;amp;TR&amp;amp;' REBS')),if(rangemax(TR+.1,A+.01,STL+.001)=A+.01,if(A=0,'',if(A=1,', ASST',', '&amp;amp;A&amp;amp;' ASSTS')),if(STL=0,'',if(STL=1,', STL',', '&amp;amp;STL&amp;amp;' STLS')))))&lt;/P&gt;&lt;P&gt;)))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Oct 2015 14:29:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/rangemax-function-2nd-highest-value/m-p/445541#M485557</guid>
      <dc:creator />
      <dc:date>2015-10-13T14:29:47Z</dc:date>
    </item>
    <item>
      <title>Re: rangemax function - 2nd highest value</title>
      <link>https://community.qlik.com/t5/QlikView/rangemax-function-2nd-highest-value/m-p/445542#M485558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Brian, this is definitely helpful! Sunny T helped me in another thread and the ideas are similar. &lt;A href="https://community.qlik.com/thread/186501"&gt;Max value of variables or an array&lt;/A&gt;‌&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you so much for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Oct 2015 15:48:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/rangemax-function-2nd-highest-value/m-p/445542#M485558</guid>
      <dc:creator />
      <dc:date>2015-10-13T15:48:15Z</dc:date>
    </item>
    <item>
      <title>Re: rangemax function - 2nd highest value</title>
      <link>https://community.qlik.com/t5/QlikView/rangemax-function-2nd-highest-value/m-p/1876931#M1216708</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I've solved it with RangeFractile. I had to check if the column is within the top 3. RangeFractile(0.5) gives you the median. The median with 7 colmns is the 4th number. But first/third quartil is possible as well.&amp;nbsp; Is a bit easier formule.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If(A &amp;gt; RangeFractile(0.5, A, B, C, D, E, F), A, 0)&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jan 2022 09:46:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/rangemax-function-2nd-highest-value/m-p/1876931#M1216708</guid>
      <dc:creator>Maarsen</dc:creator>
      <dc:date>2022-01-04T09:46:24Z</dc:date>
    </item>
  </channel>
</rss>

