Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
Have the below data:
ID
2
4
4
6
Max(ID) returns 6
Max(ID,2) returns 4
Max(ID,3) returns 2 --> But i want it to return 4 since there are 2 4's. Anyway i can tweak the function to get this output?
Yours Truly,
S.Manikantan
May be create another field in the script like this
LOAD ID,
AutoNumber(RowNo(), ID) as SNo
FROM ...
and now try this
FirstSortedValue(ID, -(ID + SNo/1E10), 1) -> 6
FirstSortedValue(ID, -(ID + SNo/1E10), 2) -> 4
FirstSortedValue(ID, -(ID + SNo/1E10), 3) -> 4
FirstSortedValue(ID, -(ID + SNo/1E10), 4) -> 2
You might need the help of Rank() then:
May be create another field in the script like this
LOAD ID,
AutoNumber(RowNo(), ID) as SNo
FROM ...
and now try this
FirstSortedValue(ID, -(ID + SNo/1E10), 1) -> 6
FirstSortedValue(ID, -(ID + SNo/1E10), 2) -> 4
FirstSortedValue(ID, -(ID + SNo/1E10), 3) -> 4
FirstSortedValue(ID, -(ID + SNo/1E10), 4) -> 2
Thanks Sunny & Petter.
Sunny, i have been able to use your solution for my purpose. Thanks.
Yours Truly,
S.Manikantan.