Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
Is it possible to make FirstSortedValue return values when the sorting field has same values?
For example:
if the data looks like
ID | value |
---|---|
1 | 10 |
2 | 10 |
3 | 8 |
4 | 7 |
5 | 6 |
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!
Try this -
FirstSortedValue(Distinct ID, value)
No it does work.
It brings the ID of the lowest value.
What i need is to get the second ID with highest value.
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))