<?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: First sorted value equality condition- distinct does not work in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/First-sorted-value-equality-condition-distinct-does-not-work/m-p/1857687#M70802</link>
    <description>&lt;P&gt;FirstSortedValue() returns one value - the one matching the first sorted value (DISTINCT should break ties if they exist among the sorted values, but will not help if the maximum value corresponds to multiple dimension values, in which case it will return null). It will not return multiple dimension values as you seem to be trying to do. Perhaps you could consider breaking the ties by adding or subtracting values as appropriate, e.g.&lt;/P&gt;
&lt;P&gt;if(tur='bi',total+0.0000000002, if(tur='ek',total+0.0000000001,total))&lt;/P&gt;
&lt;P&gt;That should prevent ties from happening and pick out the tur you want based on the priority you listed.&lt;/P&gt;
&lt;P&gt;Alternatively, you could probably add another load, grouped by mat and sorted by -total and tur1, and pull just the top row from that load for each mat, and then use that to get the value you want.&lt;/P&gt;</description>
    <pubDate>Wed, 10 Nov 2021 13:54:38 GMT</pubDate>
    <dc:creator>Or</dc:creator>
    <dc:date>2021-11-10T13:54:38Z</dc:date>
    <item>
      <title>First sorted value equality condition- distinct does not work</title>
      <link>https://community.qlik.com/t5/App-Development/First-sorted-value-equality-condition-distinct-does-not-work/m-p/1857651#M70797</link>
      <description>&lt;DIV class="topic-subject-wrapper"&gt;
&lt;DIV class="lia-message-subject lia-component-message-view-widget-subject"&gt;
&lt;DIV class="MessageSubject"&gt;
&lt;DIV class="lia-message-subject"&gt;First sorted value equality condition&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="MessageInResponseTo lia-component-message-view-widget-in-response-to lia-component-in-response-to"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="bodyDisplay" class="lia-message-body lia-component-message-view-widget-body lia-component-body-signature-highlight-escalation lia-component-message-view-widget-body-signature-highlight-escalation"&gt;
&lt;DIV class="lia-message-body-content"&gt;
&lt;P&gt;I used first sorted value to make my calculation, My aim was to take max of total, concatenate reasons while mat is same and print tur which corresponds to max total.&lt;/P&gt;
&lt;P&gt;However there may be equality of total for different inputs(rows). In such cases, I would like to create a priorization among turs. If there is equality in among totals&amp;nbsp; "bi" should be first to print then, "ek"and then "ka".&lt;/P&gt;
&lt;P&gt;So below case instead of - , "bi" should be printed.&lt;/P&gt;
&lt;P&gt;p.s.In case are two distinct line where tur and the total are the same,&amp;nbsp; it should print tur itself in instead of "-"&lt;/P&gt;
&lt;P&gt;Distinct does not work&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;Raw:&lt;BR /&gt;load&lt;BR /&gt;tur,&lt;BR /&gt;mat,&lt;BR /&gt;total,&lt;BR /&gt;reason&lt;BR /&gt;&lt;BR /&gt;From mysource;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Calculation:&lt;BR /&gt;LOAD&lt;BR /&gt;FirstSortedValue(tur,-total,1) as "tur1",&lt;BR /&gt;mat as mat1,&lt;BR /&gt;max(total) as total1,&lt;BR /&gt;concat(reason) as reason1&lt;/P&gt;
&lt;P&gt;Resident Raw&lt;BR /&gt;Group by mat&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 10 Nov 2021 13:14:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/First-sorted-value-equality-condition-distinct-does-not-work/m-p/1857651#M70797</guid>
      <dc:creator>ayseayse</dc:creator>
      <dc:date>2021-11-10T13:14:46Z</dc:date>
    </item>
    <item>
      <title>Re: First sorted value equality condition- distinct does not work</title>
      <link>https://community.qlik.com/t5/App-Development/First-sorted-value-equality-condition-distinct-does-not-work/m-p/1857687#M70802</link>
      <description>&lt;P&gt;FirstSortedValue() returns one value - the one matching the first sorted value (DISTINCT should break ties if they exist among the sorted values, but will not help if the maximum value corresponds to multiple dimension values, in which case it will return null). It will not return multiple dimension values as you seem to be trying to do. Perhaps you could consider breaking the ties by adding or subtracting values as appropriate, e.g.&lt;/P&gt;
&lt;P&gt;if(tur='bi',total+0.0000000002, if(tur='ek',total+0.0000000001,total))&lt;/P&gt;
&lt;P&gt;That should prevent ties from happening and pick out the tur you want based on the priority you listed.&lt;/P&gt;
&lt;P&gt;Alternatively, you could probably add another load, grouped by mat and sorted by -total and tur1, and pull just the top row from that load for each mat, and then use that to get the value you want.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 13:54:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/First-sorted-value-equality-condition-distinct-does-not-work/m-p/1857687#M70802</guid>
      <dc:creator>Or</dc:creator>
      <dc:date>2021-11-10T13:54:38Z</dc:date>
    </item>
  </channel>
</rss>

