Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

FirstSortedValue function gives no results

     Hello,

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.

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.

Here is my situation:

I'm using the following function to return the value for [Op tijd] with the first value in the dataset of week(datum)

=FirstSortedValue([Op tijd],week(Datum))

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.

=FirstSortedValue([Op tijd],-week(Datum)) --> I saw using the minus sign in front of the week(datum) should turn around the sorting. Unfortunatly this returns '-'.

Then I've tried it with sorting:

=FirstSortedValue([Op tijd],week(Datum), count(week(datum)) --> 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.

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.

What am I doing wrong here?

Kind regards,

Stefan

1 Reply
sunny_talwar

Is it possible for you to have more than one value for the max Week(Datum)?

May be you need this:

=FirstSortedValue(DISTINCT [Op tijd],-Week(Datum))

or are you trying to get Sum of Op tijd for the max week?