<?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 using a non numeric field to sort in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/FirstSortedValue-using-a-non-numeric-field-to-sort/m-p/2016054#M83937</link>
    <description>&lt;P&gt;I believe that FirstSortedValue() requires a numeric input for the sort_order parameter, so you can input anything as long as it has a numeric representation - a number, a date, a dual() field, etc.&lt;/P&gt;
&lt;P&gt;In the above example, you could have created Dual(Sort,KeepChar('0123456789')) and used that for both purposes (Note that this is the same as the purgechar but allows for characters other than M to be removed). If those characters are additionally necessary, you could do some creative string/math manipulation, such as:&lt;/P&gt;
&lt;P&gt;Ord(Left(Sort,1))*100 + KeepChar('0123456789') // This would sort based on the first letter alphabetically and then based on the remaining numeric value&lt;/P&gt;</description>
    <pubDate>Tue, 13 Dec 2022 15:34:55 GMT</pubDate>
    <dc:creator>Or</dc:creator>
    <dc:date>2022-12-13T15:34:55Z</dc:date>
    <item>
      <title>FirstSortedValue using a non numeric field to sort</title>
      <link>https://community.qlik.com/t5/App-Development/FirstSortedValue-using-a-non-numeric-field-to-sort/m-p/2016043#M83936</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a table with 3 fields:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Base data" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/96089iBCE396834268360F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2022-12-13 at 12.14.19.png" alt="Base data" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Base data&lt;/span&gt;&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For each Category, I need to retrieve the value corresponding to the lowest Sort. The chart function FirstSortedValue seems to be the answer. However, I could not make it work. It always returned Null.&lt;/P&gt;&lt;P&gt;I searched for an answer on the Community, but could not find. Then I asked for&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/25713"&gt;@rafaelattux&lt;/a&gt;&amp;nbsp;help, and he made it work by transforming the Sort field into a number. See below both attempts:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="FirstSortedValue" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/96090i8A8E2DF7CC240504/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2022-12-13 at 12.19.48.png" alt="FirstSortedValue" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;FirstSortedValue&lt;/span&gt;&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;Original formula returning Null:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;=FirstSortedValue([Value],[Sort])&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Attux's formula returning the right answer:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;=FirstSortedValue([Value],PurgeChar([Sort],'M'))&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can we conclude that FirstSortedValue can only be used with numeric values or dates(I found some discussions on the forum for dates) in the sort parameters?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot for your help.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Dec 2022 15:24:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/FirstSortedValue-using-a-non-numeric-field-to-sort/m-p/2016043#M83936</guid>
      <dc:creator>jmbenedetto</dc:creator>
      <dc:date>2022-12-13T15:24:35Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue using a non numeric field to sort</title>
      <link>https://community.qlik.com/t5/App-Development/FirstSortedValue-using-a-non-numeric-field-to-sort/m-p/2016054#M83937</link>
      <description>&lt;P&gt;I believe that FirstSortedValue() requires a numeric input for the sort_order parameter, so you can input anything as long as it has a numeric representation - a number, a date, a dual() field, etc.&lt;/P&gt;
&lt;P&gt;In the above example, you could have created Dual(Sort,KeepChar('0123456789')) and used that for both purposes (Note that this is the same as the purgechar but allows for characters other than M to be removed). If those characters are additionally necessary, you could do some creative string/math manipulation, such as:&lt;/P&gt;
&lt;P&gt;Ord(Left(Sort,1))*100 + KeepChar('0123456789') // This would sort based on the first letter alphabetically and then based on the remaining numeric value&lt;/P&gt;</description>
      <pubDate>Tue, 13 Dec 2022 15:34:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/FirstSortedValue-using-a-non-numeric-field-to-sort/m-p/2016054#M83937</guid>
      <dc:creator>Or</dc:creator>
      <dc:date>2022-12-13T15:34:55Z</dc:date>
    </item>
  </channel>
</rss>

