<?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 weird behavior in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Firstsortedvalue-weird-behavior/m-p/2533679#M108259</link>
    <description>&lt;P&gt;With some input from my colleague&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/6152"&gt;@Oleg_Troyansky&lt;/a&gt;&amp;nbsp;I think I can explain. First you need to add a second 3/10 value to make your example equal to App B. I'll also add a record id for illustration.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Load *, RecNo() as RecNo inline [&lt;BR /&gt;Date, Price&lt;BR /&gt;1/10/2025,15&lt;BR /&gt;2/10/2025,18&lt;BR /&gt;2/10/2025,19&lt;BR /&gt;3/10/2025,25&lt;BR /&gt;3/10/2025,30&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;While it's true that the Aggr() returns three values, they get associated back to the five Date rows. You can see this if you add the RecNo to a chart:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rwunderlich_0-1760663508683.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/184282iC33987A914F1C1BC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="rwunderlich_0-1760663508683.png" alt="rwunderlich_0-1760663508683.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hence there are two values associated with the last Date, so you must use DISTINCT.&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;</description>
    <pubDate>Sat, 25 Oct 2025 22:38:07 GMT</pubDate>
    <dc:creator>rwunderlich</dc:creator>
    <dc:date>2025-10-25T22:38:07Z</dc:date>
    <item>
      <title>Firstsortedvalue weird behavior</title>
      <link>https://community.qlik.com/t5/App-Development/Firstsortedvalue-weird-behavior/m-p/2533670#M108256</link>
      <description>&lt;P&gt;Hello, please see scenario below:&amp;nbsp;&lt;/P&gt;&lt;P&gt;App A:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Based on sample data:&lt;/P&gt;&lt;P&gt;Load * inline [&lt;BR /&gt;Date, Price&lt;BR /&gt;1/10/2025,10&lt;BR /&gt;1/10/2025,12&lt;BR /&gt;1/10/2025,15&lt;BR /&gt;2/10/2025,18&lt;BR /&gt;2/10/2025,19&lt;BR /&gt;3/10/2025,25&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;Close = Avg(price)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SGV_1-1760646393264.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/184277iE435F3F1375095C5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SGV_1-1760646393264.png" alt="SGV_1-1760646393264.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;App B:&lt;/P&gt;&lt;P&gt;Without Distinct keyword&lt;/P&gt;&lt;P&gt;Close = Avg(price)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SGV_2-1760646590892.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/184278i16D10A7C380FFA19/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SGV_2-1760646590892.png" alt="SGV_2-1760646590892.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;With Distinct Keyword&lt;/P&gt;&lt;P&gt;Close = Avg(price)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SGV_3-1760646746635.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/184279iBECD627D1B938D50/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SGV_3-1760646746635.png" alt="SGV_3-1760646746635.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Not sure what is causing the Firstsortedvalue to work with a Distinct. Since the Aggregation should output only a distinct value per row by default right? Maybe beacuse the Date field is derived from a Timestamp field?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is, am I hallucinating? or have I missed a simple trick. Please assist.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/6148"&gt;@rwunderlich&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/6622"&gt;@hic&lt;/a&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Oct 2025 21:06:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Firstsortedvalue-weird-behavior/m-p/2533670#M108256</guid>
      <dc:creator>SGV</dc:creator>
      <dc:date>2025-10-16T21:06:10Z</dc:date>
    </item>
    <item>
      <title>Re: Firstsortedvalue weird behavior</title>
      <link>https://community.qlik.com/t5/App-Development/Firstsortedvalue-weird-behavior/m-p/2533679#M108259</link>
      <description>&lt;P&gt;With some input from my colleague&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/6152"&gt;@Oleg_Troyansky&lt;/a&gt;&amp;nbsp;I think I can explain. First you need to add a second 3/10 value to make your example equal to App B. I'll also add a record id for illustration.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Load *, RecNo() as RecNo inline [&lt;BR /&gt;Date, Price&lt;BR /&gt;1/10/2025,15&lt;BR /&gt;2/10/2025,18&lt;BR /&gt;2/10/2025,19&lt;BR /&gt;3/10/2025,25&lt;BR /&gt;3/10/2025,30&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;While it's true that the Aggr() returns three values, they get associated back to the five Date rows. You can see this if you add the RecNo to a chart:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rwunderlich_0-1760663508683.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/184282iC33987A914F1C1BC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="rwunderlich_0-1760663508683.png" alt="rwunderlich_0-1760663508683.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hence there are two values associated with the last Date, so you must use DISTINCT.&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;</description>
      <pubDate>Sat, 25 Oct 2025 22:38:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Firstsortedvalue-weird-behavior/m-p/2533679#M108259</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2025-10-25T22:38:07Z</dc:date>
    </item>
  </channel>
</rss>

