Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How do I edit a RANK statement ?

Hi Experts,

I want to rank a field based on its value. The RANK statement is ideal for this purpose. However, if I have values in the column which are the same then QlikView displays the range of ordinal numbers.

For example, if the top 4 records all have the same value (67) QlikView displays the rank of each as 1-4. However, I want the rankings to display as 1, because they are all in equal first position.

How do I do this ?

Thanks

MV

1 Reply
swuehl
MVP
MVP

There are two more optional arguments to rank() function you can use for that (refer to the HELP):

The second parameter mode specifies the number representation of the function result.

mode

   

0 (default)If all ranks within the sharing group fall on the low side of the middle value of the entire ranking, all rows get the lowest rank within the sharing group.
If all ranks within the sharing group fall on the high side of the middle value of the entire ranking, all rows get the highest rank within the sharing group.
If ranks within the sharing group span over the middle value of the entire ranking, all rows get the value corresponding to the average of the top and bottom ranking in the entire column segment.
1Lowest rank on all rows.
2Average rank on all rows.
3Highest rank on all rows.
4Lowest rank on first row, then incremented by one for each row.

The third parameter format specifies the text representation of the function result.

format

   

0 (default)Low value&' - '&high value on all rows (e.g. 3 - 4).
1Low value on all rows.
2Low value on first row, blank on the following rows.

So, this should return what you want:

=rank(YourExpression,1,1)