<?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() with aggr()? in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/FirstSortedValue-with-aggr/m-p/2142468#M92936</link>
    <description>&lt;P&gt;Hello Marcin,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The&lt;I&gt; FirstSortedValue()&lt;/I&gt; function in Qlik Sense returns the value from the expression specified in value that corresponds to the result of sorting the &lt;I&gt;sort_weight argument&lt;/I&gt;. The nth value in the sort order can be specified in&lt;I&gt; rank.&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, when you’re using &lt;I&gt;FirstSortedValue()&lt;/I&gt; with an offset of 2, it’s important to note that this function will return null if there are not at least two distinct values in the&lt;I&gt; sort_weight&lt;/I&gt; argument for the same value argument. This could be the reason why you’re encountering null values.&lt;/P&gt;
&lt;P&gt;If you’re trying to calculate the time interval between individual events, you might need to adjust your data model or the way you’re using the function. For example, you could try using the &lt;I&gt;Above() &lt;/I&gt;or&lt;I&gt; Below() &lt;/I&gt;functions to reference previous or next rows in a table, or consider restructuring your data so that each event is on a separate row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For more information, please take a look below&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://help.qlik.com/en-US/sense/August2021/Subsystems/Hub/Content/Sense_Hub/Scripting/AggregationFunctions/firstsorted.htm" target="_blank"&gt;FirstSortedValue - script function | Qlik Sense on Windows Help&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/AggregationFunctions/firstsorted.htm" target="_blank"&gt;FirstSortedValue - script function | Qlik Cloud Help&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Nov 2023 15:31:22 GMT</pubDate>
    <dc:creator>Chirantha</dc:creator>
    <dc:date>2023-11-29T15:31:22Z</dc:date>
    <item>
      <title>FirstSortedValue() with aggr()?</title>
      <link>https://community.qlik.com/t5/App-Development/FirstSortedValue-with-aggr/m-p/2142463#M92935</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I'm having an issue with the FirstSortedValue() function. When I try to get the previous event to calculate the time interval between individual events, I encounter a null value. If I set the offset to 1, the function works, but I need to set the offset to 2 to append the timestamp of event B to event A, and that's the problem. Please help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;FirstSortedValue(DISTINCT aggr( max(Timestamp), ID),Timestamp,1) - on screen and it is working&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;FirstSortedValue(DISTINCT aggr( max(Timestamp), ID),Timestamp,2) - on second screen, it isn't working but I can see one correct value in sum row hm....&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Marcin&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 15:31:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/FirstSortedValue-with-aggr/m-p/2142463#M92935</guid>
      <dc:creator>MarcinS</dc:creator>
      <dc:date>2023-11-29T15:31:47Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue() with aggr()?</title>
      <link>https://community.qlik.com/t5/App-Development/FirstSortedValue-with-aggr/m-p/2142468#M92936</link>
      <description>&lt;P&gt;Hello Marcin,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The&lt;I&gt; FirstSortedValue()&lt;/I&gt; function in Qlik Sense returns the value from the expression specified in value that corresponds to the result of sorting the &lt;I&gt;sort_weight argument&lt;/I&gt;. The nth value in the sort order can be specified in&lt;I&gt; rank.&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, when you’re using &lt;I&gt;FirstSortedValue()&lt;/I&gt; with an offset of 2, it’s important to note that this function will return null if there are not at least two distinct values in the&lt;I&gt; sort_weight&lt;/I&gt; argument for the same value argument. This could be the reason why you’re encountering null values.&lt;/P&gt;
&lt;P&gt;If you’re trying to calculate the time interval between individual events, you might need to adjust your data model or the way you’re using the function. For example, you could try using the &lt;I&gt;Above() &lt;/I&gt;or&lt;I&gt; Below() &lt;/I&gt;functions to reference previous or next rows in a table, or consider restructuring your data so that each event is on a separate row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For more information, please take a look below&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://help.qlik.com/en-US/sense/August2021/Subsystems/Hub/Content/Sense_Hub/Scripting/AggregationFunctions/firstsorted.htm" target="_blank"&gt;FirstSortedValue - script function | Qlik Sense on Windows Help&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/AggregationFunctions/firstsorted.htm" target="_blank"&gt;FirstSortedValue - script function | Qlik Cloud Help&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 15:31:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/FirstSortedValue-with-aggr/m-p/2142468#M92936</guid>
      <dc:creator>Chirantha</dc:creator>
      <dc:date>2023-11-29T15:31:22Z</dc:date>
    </item>
  </channel>
</rss>

