<?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 function gives no results in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-function-gives-no-results/m-p/1197176#M386029</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've stumbled upon a little problem in working with the FirstSortedValue function. I saw many topics on it, but I could not find the one with the right anwers for me.&lt;/P&gt;&lt;P&gt;I'm working on the prediction model in which i use certain variables based on the history. For this model I'm using for instance the first and the value of an value sorted by date. The FirstSortedValue function is great for this, but I can't manage to make it work for the last value, and I'm not sure what's the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my situation:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using the following function to return the value for [Op tijd] with the first value in the dataset of week(datum)&lt;/P&gt;&lt;P&gt;=FirstSortedValue([Op tijd],week(Datum))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, far no problem. But when I try to return the last value from the data set this doesn't work. I've tried the following functions.&lt;/P&gt;&lt;P&gt;=FirstSortedValue([Op tijd],-week(Datum)) --&amp;gt; I saw using the minus sign in front of the week(datum) should turn around the sorting. Unfortunatly this returns '-'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I've tried it with sorting:&lt;/P&gt;&lt;P&gt;=FirstSortedValue([Op tijd],week(Datum), count(week(datum)) --&amp;gt; the count(week(datum) returns the total numbers of weeks, that value is used to return the [Op tijd]-value. That doesn't work either.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I saw this topic on using aggr for this function, I've that as well, which doesn't work for me aswell. I even tried using max(week(Datum), no luck either. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What am I doing wrong here?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stefan &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 01 Oct 2016 16:25:02 GMT</pubDate>
    <dc:creator />
    <dc:date>2016-10-01T16:25:02Z</dc:date>
    <item>
      <title>FirstSortedValue function gives no results</title>
      <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-function-gives-no-results/m-p/1197176#M386029</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've stumbled upon a little problem in working with the FirstSortedValue function. I saw many topics on it, but I could not find the one with the right anwers for me.&lt;/P&gt;&lt;P&gt;I'm working on the prediction model in which i use certain variables based on the history. For this model I'm using for instance the first and the value of an value sorted by date. The FirstSortedValue function is great for this, but I can't manage to make it work for the last value, and I'm not sure what's the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my situation:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using the following function to return the value for [Op tijd] with the first value in the dataset of week(datum)&lt;/P&gt;&lt;P&gt;=FirstSortedValue([Op tijd],week(Datum))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, far no problem. But when I try to return the last value from the data set this doesn't work. I've tried the following functions.&lt;/P&gt;&lt;P&gt;=FirstSortedValue([Op tijd],-week(Datum)) --&amp;gt; I saw using the minus sign in front of the week(datum) should turn around the sorting. Unfortunatly this returns '-'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I've tried it with sorting:&lt;/P&gt;&lt;P&gt;=FirstSortedValue([Op tijd],week(Datum), count(week(datum)) --&amp;gt; the count(week(datum) returns the total numbers of weeks, that value is used to return the [Op tijd]-value. That doesn't work either.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I saw this topic on using aggr for this function, I've that as well, which doesn't work for me aswell. I even tried using max(week(Datum), no luck either. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What am I doing wrong here?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stefan &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 01 Oct 2016 16:25:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/FirstSortedValue-function-gives-no-results/m-p/1197176#M386029</guid>
      <dc:creator />
      <dc:date>2016-10-01T16:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: FirstSortedValue function gives no results</title>
      <link>https://community.qlik.com/t5/QlikView/FirstSortedValue-function-gives-no-results/m-p/1197177#M386030</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is it possible for you to have more than one value for the max Week(Datum)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;May be you need this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;STRONG&gt;=FirstSortedValue(DISTINCT [Op tijd],-Week(Datum))&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or are you trying to get Sum of Op tijd for the max week?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Oct 2016 20:51:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/FirstSortedValue-function-gives-no-results/m-p/1197177#M386030</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2016-10-03T20:51:09Z</dc:date>
    </item>
  </channel>
</rss>

