Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

FirstSortedValue Issue

Hi Community,

I want to be able to return ID's based on their ranking in the sales field but the issue is when the 2 ID's have the same sales FirstSortedValue returns null instead of the ID. For example FirstSortedValue(Id,Sales,3) and FirstSortedValue(Id,Sales,4) return null. Please advise, thanks!

Keep Qliking!

3 Replies
JonnyPoole
Employee
Employee

Try adding 'distinct' . The expression editor flags it but its saved my bacon a few times

=FirstSortedValue( distinct ID,-Sales,3)

Not applicable
Author

Thank you, that works to give me one of the keys for the third ranked value, but I still can't get the second key that also has that same third value.  Any suggestions?

maxgro
MVP
MVP

maybe

=FirstSortedValue( Aggr(Concat(ID,','),Sales),-Aggr(Sales,Sales),3)

from here

Firstsortedvalue