<?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: I wonder in which conditions does FirstSortedValue delivers a NULL value? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/I-wonder-in-which-conditions-does-FirstSortedValue-delivers-a/m-p/1784069#M1209830</link>
    <description>&lt;P&gt;Marcus,&lt;/P&gt;&lt;P&gt;thank you for your extended answer!&lt;/P&gt;&lt;P&gt;I worked on it and used some flags as you suggest.&lt;/P&gt;&lt;P&gt;Do you have a hint for me where I can deepen your suggestion: &lt;EM&gt;"flagging the appropriate values with interrecord-functions like previous() or peek()"&lt;/EM&gt;?&lt;/P&gt;&lt;P&gt;- Alexandru&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 19 Feb 2021 07:52:01 GMT</pubDate>
    <dc:creator>draghici1109</dc:creator>
    <dc:date>2021-02-19T07:52:01Z</dc:date>
    <item>
      <title>I wonder in which conditions does FirstSortedValue delivers a NULL value?</title>
      <link>https://community.qlik.com/t5/QlikView/I-wonder-in-which-conditions-does-FirstSortedValue-delivers-a/m-p/1781865#M1209560</link>
      <description>&lt;P&gt;Hello everybody!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am rookie waiting for the next Qlik Scripting Training next week. However I have to solve following problem: I use FirstSortedValue with INLINE Table. The same algorythm and the same field names I use the second time by reading the fields as paramater for FirstSortedValue from a qvd file on the disk.&lt;/P&gt;&lt;P&gt;Challenge: 1st time I use FirstSortedValue delivers the right results. 2nd time I run it with data loaded from a qdf file deliver me NULL values as a result of the execution of the FirstSortedValue. I do not see the difference and have no explanation for the NULL values.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I wonder in which conditions does FirstSortedValue delivers a NULL value?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Here my code:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;GIMEL:&lt;BR /&gt;LOAD * INLINE&lt;BR /&gt;[&lt;BR /&gt;TABNR, TABNRuTABSEQNR, TABSEQNR&lt;BR /&gt;HP2-----200A00000000000000018801, HP2-----200A00000000000000018801|00004, 00004&lt;BR /&gt;HP2-----200A00000000000000018801, HP2-----200A00000000000000018801|00005, 00005&lt;BR /&gt;HP2-----200A00000000000000018802, HP2-----200A00000000000000018802|00008, 00008&lt;BR /&gt;HP2-----200A00000000000000018802, HP2-----200A00000000000000018802|00007, 00007&lt;BR /&gt;HP2-----200A00000000000000018833, HP2-----200A00000000000000018833|00004, 00004&lt;BR /&gt;HP2-----200A00000000000000018833, HP2-----200A00000000000000018833|00010, 00010&lt;BR /&gt;HP2-----200A00000000000000018833, HP2-----200A00000000000000018833|00005, 00005&lt;BR /&gt;HP2-----200A00000000000000018833, HP2-----200A00000000000000018833|00006, 00006&lt;BR /&gt;HP2-----200A00000000000000018833, HP2-----200A00000000000000018833|00009, 00009&lt;BR /&gt;HP2-----200A00000000000000018833, HP2-----200A00000000000000018833|00003, 00003&lt;BR /&gt;HP2-----200A00000000000000018833, HP2-----200A00000000000000018833|00002, 00002&lt;BR /&gt;HP2-----200A00000000000000018833, HP2-----200A00000000000000018833|00001, 00001&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;DALET:&lt;BR /&gt;LOAD&lt;BR /&gt;TABNR,&lt;BR /&gt;FirstSortedValue(TABNRuTABSEQNR, TABSEQNR) AS TABNRuTABSEQNR&lt;BR /&gt;Resident GIMEL&lt;BR /&gt;GROUP BY TABNR;&lt;/P&gt;&lt;P&gt;STORE [DALET] INTO [..\DATA_20\DALET.qvd](qvd);&lt;BR /&gt;Drop Table [DALET], [GIMEL];&lt;/P&gt;&lt;P&gt;// Results are here:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="draghici1109_0-1613027521963.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/48884iCDFA2617F4E1F18F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="draghici1109_0-1613027521963.png" alt="draghici1109_0-1613027521963.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// The same logic with the same field name is now implemented by loading data not with INLINE but rather&lt;BR /&gt;// from a qvd file named VorbereitungHKSTL.qvd&lt;/P&gt;&lt;P&gt;HE:&lt;BR /&gt;//TABNRuTABSEQNR will be later used as key for joining with the rest of the fields of VorbereitungHKSTL&lt;BR /&gt;LOAD&lt;BR /&gt;TABNR,&lt;BR /&gt;TABNR &amp;amp; '|' &amp;amp; TABSEQNR AS TABNRuTABSEQNR,&lt;BR /&gt;TABSEQNR&lt;/P&gt;&lt;P&gt;FROM [..\DATA_20\VorbereitungHKSTL.qvd](qvd);&lt;BR /&gt;STORE [HE] INTO [..\DATA_20\HE.qvd](qvd);&lt;BR /&gt;Drop Table [HE];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Sample Data VorbereitungHKSTL:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="draghici1109_1-1613027704400.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/48885i5E10F5DB873B53CD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="draghici1109_1-1613027704400.png" alt="draghici1109_1-1613027704400.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAV:&lt;BR /&gt;LOAD&lt;BR /&gt;TABNR,&lt;BR /&gt;FirstSortedValue(TABNRuTABSEQNR, TABSEQNR) AS TABNRuTABSEQNR&lt;BR /&gt;FROM [..\DATA_20\HE.qvd](qvd)&lt;BR /&gt;GROUP BY TABNR;&lt;BR /&gt;STORE [VAV] INTO [..\DATA_20\VAV.qvd](qvd);&lt;BR /&gt;Drop Table [VAV];&lt;/P&gt;&lt;P&gt;// VAV.qvd sample, the second field contains NULL&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="draghici1109_2-1613027817287.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/48886i5E017F1452FE40E7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="draghici1109_2-1613027817287.png" alt="draghici1109_2-1613027817287.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EXIT SCRIPT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2021 07:17:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/I-wonder-in-which-conditions-does-FirstSortedValue-delivers-a/m-p/1781865#M1209560</guid>
      <dc:creator>draghici1109</dc:creator>
      <dc:date>2021-02-11T07:17:55Z</dc:date>
    </item>
    <item>
      <title>Re: I wonder in which conditions does FirstSortedValue delivers a NULL value?</title>
      <link>https://community.qlik.com/t5/QlikView/I-wonder-in-which-conditions-does-FirstSortedValue-delivers-a/m-p/1782318#M1209631</link>
      <description>&lt;P&gt;Firstsortedvalue() returns NULL if there are multiple different return-values for the appropriate lookup-value available. It's a bit similar like the function only().&lt;/P&gt;&lt;P&gt;Your noticed differences are probably caused from the differences between both used datasets. The inline-table has just a few records and so the likely that a lookup-value has multiple return-values is rather small but if there is a bigger dataset like in the qvd the likely increased.&lt;/P&gt;&lt;P&gt;This means firstsortedvalue() is only in very specific scenarios usable. In your case you may rather use max() / maxstring() or using different approaches like sorting the data and flagging the appropriate values with interrecord-functions like previous() or peek() or also a mapping/joining based on maxstring() or similar to flag/filter the dataset.&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2021 14:33:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/I-wonder-in-which-conditions-does-FirstSortedValue-delivers-a/m-p/1782318#M1209631</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2021-02-12T14:33:49Z</dc:date>
    </item>
    <item>
      <title>Re: I wonder in which conditions does FirstSortedValue delivers a NULL value?</title>
      <link>https://community.qlik.com/t5/QlikView/I-wonder-in-which-conditions-does-FirstSortedValue-delivers-a/m-p/1784069#M1209830</link>
      <description>&lt;P&gt;Marcus,&lt;/P&gt;&lt;P&gt;thank you for your extended answer!&lt;/P&gt;&lt;P&gt;I worked on it and used some flags as you suggest.&lt;/P&gt;&lt;P&gt;Do you have a hint for me where I can deepen your suggestion: &lt;EM&gt;"flagging the appropriate values with interrecord-functions like previous() or peek()"&lt;/EM&gt;?&lt;/P&gt;&lt;P&gt;- Alexandru&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2021 07:52:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/I-wonder-in-which-conditions-does-FirstSortedValue-delivers-a/m-p/1784069#M1209830</guid>
      <dc:creator>draghici1109</dc:creator>
      <dc:date>2021-02-19T07:52:01Z</dc:date>
    </item>
    <item>
      <title>Re: I wonder in which conditions does FirstSortedValue delivers a NULL value?</title>
      <link>https://community.qlik.com/t5/QlikView/I-wonder-in-which-conditions-does-FirstSortedValue-delivers-a/m-p/1784085#M1209832</link>
      <description>&lt;P&gt;Within a sorted resident-load - something like:&lt;/P&gt;&lt;P&gt;...&lt;BR /&gt;order by Field1, Field2 desc;&lt;/P&gt;&lt;P&gt;and then you may use an calculation like this one:&lt;/P&gt;&lt;P&gt;if(Field1 &amp;lt;&amp;gt; previous(Field1), 1, rangesum(peek('Counter'), 1)) as Counter&lt;/P&gt;&lt;P&gt;to get a running counter-field in regard to your conditions.&lt;/P&gt;&lt;P&gt;This means you need to assure that the load is sorted properly and that you query the values from the current record against the previous ones. Depending on the number of relevant fields and/or the complexity of the requirement you might need more as a single if-loop else nested ones and also several loads if the sorting needs to be either ascending as well as descending - which may exclude each other within a single load.&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2021 09:01:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/I-wonder-in-which-conditions-does-FirstSortedValue-delivers-a/m-p/1784085#M1209832</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2021-02-19T09:01:46Z</dc:date>
    </item>
  </channel>
</rss>

