Qlik Community

Ask a Question

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Talk to Experts Tuesday, January 26th at 10AM EST: Qlik Sense. REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Creator
Creator

FirstSortedValue with same value

Hi,

Is it possible to make FirstSortedValue return values when the sorting field has same values?

For example:

if the data looks like

IDvalue
110
210
38
47
56

If I do

FirstSortedValue(Distinct ID, -value) then i get 1

But what if I want to get ID 2?

Can I do something thing like

FirstSortedValue(Distinct ID, -value, 2)

I tried but it does not work.

any suggestions?

Thanks!

3 Replies
Specialist II
Specialist II

Try this -

FirstSortedValue(Distinct ID, value)

Creator
Creator

No it does work.

It brings the ID of the lowest value.

What i need is to get the second ID with highest value.

Champion III
Champion III

Not sure if this is a good way of doing it but you can try below options:

Option1:

=Firstsortedvalue(Aggr(Max(ID), value), Aggr(Max(value, -2), value))

Option2: Tweak in the script like:

Ranking:

LOAD *, Autonumber(ID, value) AS IDRank;

LOAD ID,

     value

FROM

[https://community.qlik.com/thread/314058]

(html, codepage is 1252, embedded labels, table is @1);

Add straight table chart with

Dim:

value

Expr:

= Firstsortedvalue(ID, -Aggr(IDRank, ID))