Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Max Function when there are Identical Values

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

1 Solution

Accepted Solutions
sunny_talwar
MVP
MVP

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


Capture.PNG

View solution in original post

3 Replies
petter
Partner - Champion III
Partner - Champion III

sunny_talwar
MVP
MVP

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


Capture.PNG

Anonymous
Not applicable
Author

Thanks Sunny & Petter.

Sunny, i have been able to use your solution for my purpose. Thanks.

Yours Truly,

S.Manikantan.