<?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 FirstSortedValue VS Max in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-VS-Max/m-p/164157#M36957</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you all for the answers!&lt;/P&gt;&lt;P&gt;My problem is how John says: Firstsortedvalue() return null when there are multiple values that are first by your sort order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thansk again&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 14 Jan 2011 09:37:26 GMT</pubDate>
    <dc:creator />
    <dc:date>2011-01-14T09:37:26Z</dc:date>
    <item>
      <title>FirstSortedValue VS Max</title>
      <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-VS-Max/m-p/164154#M36954</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;i don't understand because the 2 scripts are different....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;scriptA:&lt;/P&gt;&lt;P&gt;load key,&lt;/P&gt;&lt;P&gt;max(x) as x&lt;/P&gt;&lt;P&gt;resident myTable&lt;/P&gt;&lt;P&gt;group by key;&lt;/P&gt;&lt;P&gt;left join&lt;/P&gt;&lt;P&gt;LOAD key,&lt;/P&gt;&lt;P&gt;x,&lt;/P&gt;&lt;P&gt;val&lt;/P&gt;&lt;P&gt;resident myTable;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;scriptB:&lt;/P&gt;&lt;P&gt;load key,&lt;/P&gt;&lt;P&gt;firstsortedvalue(val, -x) as val&lt;/P&gt;&lt;P&gt;resident myTable&lt;/P&gt;&lt;P&gt;group by key;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Jan 2011 17:43:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/FirstSortedValue-VS-Max/m-p/164154#M36954</guid>
      <dc:creator />
      <dc:date>2011-01-11T17:43:15Z</dc:date>
    </item>
    <item>
      <title>FirstSortedValue VS Max</title>
      <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-VS-Max/m-p/164155#M36955</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;From the first look the thwo scripts should produce identical results - except maybe for a minor syntax issue. If I'm not mistaken, you need to explicitly multiply x * -1 instead of simply using "-x".&lt;/P&gt;&lt;P&gt;Other than that, I can't see a difference...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Jan 2011 18:41:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/FirstSortedValue-VS-Max/m-p/164155#M36955</guid>
      <dc:creator>Oleg_Troyansky</dc:creator>
      <dc:date>2011-01-11T18:41:50Z</dc:date>
    </item>
    <item>
      <title>FirstSortedValue VS Max</title>
      <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-VS-Max/m-p/164156#M36956</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, there's the trivial fact that the first table has x in it and the second does not. I assume that's not your concern.&lt;/P&gt;&lt;P&gt;They can produce different results depending on your data. Take this table for example:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;myTable:&lt;BR /&gt;key, x, val&lt;BR /&gt;1, 1, a&lt;BR /&gt;1, 2, b&lt;BR /&gt;1, 2, c&lt;BR /&gt;2, 1, a&lt;BR /&gt;2, 2, b&lt;/P&gt;&lt;P&gt;I expect these tables to result:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;scriptA:&lt;BR /&gt;key, x, val&lt;BR /&gt;1, 2, b&lt;BR /&gt;1, 2, c&lt;BR /&gt;2, 2, b&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;scriptB:&lt;BR /&gt;key, val&lt;BR /&gt;1, null&lt;BR /&gt;2, b&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;&lt;/P&gt;&lt;P&gt;The difference results from having two different val corresponding to key = 1 and x = 2. Firstsortedvalue() will return null when there are multiple values that are first by your sort order, while your left join will generate an extra row for each such value.&lt;/P&gt;&lt;P&gt;I don't know if that's the specific difference you're seeing since you gave no example data or example results, but it's &lt;EM&gt;A&lt;/EM&gt; difference between the two scripts.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jan 2011 00:33:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/FirstSortedValue-VS-Max/m-p/164156#M36956</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-01-12T00:33:42Z</dc:date>
    </item>
    <item>
      <title>FirstSortedValue VS Max</title>
      <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-VS-Max/m-p/164157#M36957</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you all for the answers!&lt;/P&gt;&lt;P&gt;My problem is how John says: Firstsortedvalue() return null when there are multiple values that are first by your sort order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thansk again&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Jan 2011 09:37:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/FirstSortedValue-VS-Max/m-p/164157#M36957</guid>
      <dc:creator />
      <dc:date>2011-01-14T09:37:26Z</dc:date>
    </item>
  </channel>
</rss>

