<?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 returns NULL despite unique maximum date - detailed example in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-returns-NULL-despite-unique-maximum-date/m-p/2546736#M1334757</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/79525"&gt;@hamid&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;using the data sample you provided, I'm unfortunately unable to recreate your issue. The formula you used returns 'Oui', as expected.&lt;/P&gt;&lt;P&gt;Have you checked the tables properties in the Data model viewer? Especially "Density" and "Has duplicates".&lt;/P&gt;&lt;P&gt;Are you using any set expressions you didn't post here?&lt;/P&gt;&lt;P&gt;Which vizualization are you using with which dimensions?&lt;/P&gt;</description>
    <pubDate>Mon, 13 Apr 2026 15:16:26 GMT</pubDate>
    <dc:creator>lennart_mo</dc:creator>
    <dc:date>2026-04-13T15:16:26Z</dc:date>
    <item>
      <title>FirstSortedValue returns NULL despite unique maximum date - detailed example</title>
      <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-returns-NULL-despite-unique-maximum-date/m-p/2546734#M1334756</link>
      <description>&lt;P class=""&gt;Hello Qlik Community,&lt;/P&gt;&lt;P class=""&gt;I'm encountering an unexpected behavior with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;FirstSortedValue&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and would appreciate your insights.&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;Context:&lt;/STRONG&gt;&lt;BR /&gt;I have a table tracking employee appointments with fields:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;EmployeeID&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(id_dim_salarie)&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;VisitID&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(id_visite_unique)&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;DateTime&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(date_consultation) - numeric Excel datetime&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;Teleconsult&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(teleconsultation) - text field ("Oui"/"Non")&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P class=""&gt;&lt;STRONG&gt;Goal:&lt;/STRONG&gt;&lt;BR /&gt;For each employee, retrieve the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Teleconsult&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;value from their&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;latest appointment&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(maximum&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;DateTime).&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;Expression used:&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV class=""&gt;text&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;FirstSortedValue(teleconsultation, -Num(date_consultation))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P class=""&gt;&lt;STRONG&gt;Sample data (attached: Data_exploration.xlsx):&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;EmployeeID VisitID DateTime Status Reason Teleconsult 1000011682 10000116822025-07-15 09:00 2025-07-15 09:00:00.000 Annulée Erreur de saisie Oui 1000011682 10000116822025-07-22 10:15 2025-07-22 10:15:00.000 Annulée Absence excusée Oui&lt;/DIV&gt;&lt;/DIV&gt;&lt;P class=""&gt;&lt;STRONG&gt;Expected result for EmployeeID 1000011682:&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;Latest date:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;2025-07-22 10:15:00.000&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(Excel numeric:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;45860.4270833333)&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;Teleconsult&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;value at that date:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;"Oui"&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;&lt;STRONG&gt;Should return:&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;"Oui"&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P class=""&gt;&lt;STRONG&gt;Actual result:&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;NULL&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;Debug information I've verified:&lt;/STRONG&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P class=""&gt;Max(date_consultation)&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;=&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;45860.4270833333&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;✓ (correct latest date)&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;Count(DISTINCT date_consultation)&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;= 2 ✓ (two distinct dates)&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;Count(teleconsultation)&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;= 2 ✓ (both lines have valid "Oui" values)&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;No NULL values in&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;teleconsultation&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;for this employee ✓&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;Dates are properly loaded as numeric datetime values&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P class=""&gt;According to the documentation,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;FirstSortedValue&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;should return NULL only when "more than one resulting value shares the same sort_weight for the specified rank". Here I have a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;unique maximum date&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;with a valid&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;teleconsultation&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;value.&lt;/P&gt;&lt;P class=""&gt;Why does this expression return&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;NULL? Is there something about the numeric datetime format or the specific context that's causing this behavior?&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2026 14:52:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/FirstSortedValue-returns-NULL-despite-unique-maximum-date/m-p/2546734#M1334756</guid>
      <dc:creator>hamid</dc:creator>
      <dc:date>2026-04-13T14:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue returns NULL despite unique maximum date - detailed example</title>
      <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-returns-NULL-despite-unique-maximum-date/m-p/2546736#M1334757</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/79525"&gt;@hamid&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;using the data sample you provided, I'm unfortunately unable to recreate your issue. The formula you used returns 'Oui', as expected.&lt;/P&gt;&lt;P&gt;Have you checked the tables properties in the Data model viewer? Especially "Density" and "Has duplicates".&lt;/P&gt;&lt;P&gt;Are you using any set expressions you didn't post here?&lt;/P&gt;&lt;P&gt;Which vizualization are you using with which dimensions?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2026 15:16:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/FirstSortedValue-returns-NULL-despite-unique-maximum-date/m-p/2546736#M1334757</guid>
      <dc:creator>lennart_mo</dc:creator>
      <dc:date>2026-04-13T15:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue returns NULL despite unique maximum date - detailed example</title>
      <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-returns-NULL-despite-unique-maximum-date/m-p/2546739#M1334758</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using the expression in the script as bellow:&lt;/P&gt;&lt;DIV&gt;LOAD&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; id_dim_salarie ,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; Timestamp(Max(date_consultation) ) as Last,&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; FirstSortedValue(teleconsultation, -Num(date_consultation)) as last_consultaiton&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; From...&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; Groupe by id_dim_salarie&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Mon, 13 Apr 2026 15:37:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/FirstSortedValue-returns-NULL-despite-unique-maximum-date/m-p/2546739#M1334758</guid>
      <dc:creator>hamid</dc:creator>
      <dc:date>2026-04-13T15:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue returns NULL despite unique maximum date - detailed example</title>
      <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-returns-NULL-despite-unique-maximum-date/m-p/2546741#M1334759</link>
      <description>&lt;P&gt;Could you please check if your variables set to these formats?&lt;/P&gt;&lt;P&gt;SET DateFormat='DD/MM/YYYY';&lt;BR /&gt;SET TimestampFormat='YYYY-MM-DD hh:mm:ss[,fff]';&lt;/P&gt;&lt;P&gt;Or if you do not want to alter these try:&amp;nbsp;&lt;/P&gt;&lt;P&gt;FirstSortedValue(teleconsultation, -num(date#(date_consultation, 'YYYY-MM-DD hh:mm:ss[,fff]'))&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2026 15:57:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/FirstSortedValue-returns-NULL-despite-unique-maximum-date/m-p/2546741#M1334759</guid>
      <dc:creator>lennart_mo</dc:creator>
      <dc:date>2026-04-13T15:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue returns NULL despite unique maximum date - detailed example</title>
      <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-returns-NULL-despite-unique-maximum-date/m-p/2546763#M1334760</link>
      <description>&lt;P&gt;Weird as it works fine for me as well. I tried in Qlik Sense, may be the attached app can help to understand the difference you have in your app.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2026 01:50:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/FirstSortedValue-returns-NULL-despite-unique-maximum-date/m-p/2546763#M1334760</guid>
      <dc:creator>Digvijay_Singh</dc:creator>
      <dc:date>2026-04-14T01:50:08Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue returns NULL despite unique maximum date - detailed example</title>
      <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-returns-NULL-despite-unique-maximum-date/m-p/2546783#M1334761</link>
      <description>&lt;P&gt;Actually i have this Date format on the DB :&amp;nbsp;2025-07-22 10:15:00.000000&lt;/P&gt;&lt;P&gt;And the timestamp was already set to&amp;nbsp;SET DateFormat='DD/MM/YYYY';&lt;BR /&gt;SET TimestampFormat='DD/MM/YYYY hh:mm:ss[.fff]';&lt;/P&gt;&lt;P&gt;Qlik Sense has recognise it as the date. what's weird is that ithe process works for other rows, there are some cases whare i've this bug.&lt;/P&gt;&lt;P&gt;I tried&amp;nbsp;&lt;SPAN&gt;FirstSortedValue(teleconsultation, -num(date#(date_consultation, 'YYYY-MM-DD hh:mm:ss[.fff]')) still not work&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I'm sharing then another extraction if you can check again please&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2026 08:17:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/FirstSortedValue-returns-NULL-despite-unique-maximum-date/m-p/2546783#M1334761</guid>
      <dc:creator>hamid</dc:creator>
      <dc:date>2026-04-14T08:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue returns NULL despite unique maximum date - detailed example</title>
      <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-returns-NULL-despite-unique-maximum-date/m-p/2546805#M1334762</link>
      <description>&lt;P&gt;I doubt that there is a bug else that you struggle with the number of digits and/or respectively the really stored values behind the visible ones which is caused from a technically limitation in regard to the used number-system. More hints to the matter: &lt;A href="https://community.qlik.com/t5/Design/Rounding-Errors/ba-p/1468808" target="_blank"&gt;Rounding Errors - Qlik Community - 1468808&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;I would apply a rounding to cut the values by max. 14 digits (the lesser the better) and applying recno() + rowno() + various num/text/len/isnum ... within the load and checking the results within a table-box. Afterwards I would continue in the script with the firstsortedvalue() ...&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2026 11:59:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/FirstSortedValue-returns-NULL-despite-unique-maximum-date/m-p/2546805#M1334762</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2026-04-14T11:59:40Z</dc:date>
    </item>
  </channel>
</rss>

