Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Save $600 on Qlik Connect registration! Sign up by Dec. 6 to get an extra $100 off with code CYBERSAVE: REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

how to display top 5 values by using of rank function

Hi..

  How to display top 5 values by using of rank function

1 Solution

Accepted Solutions
MK_QSL
MVP
MVP

Considering that you have customer and sales data and you want top 5 customers by sales

Create a Straight Table

Use Calculated Dimension

=IF(Aggr(Rank(SUM(Sales),4),Customer)<=5,Customer)

Expression

SUM(Sales)

Use Below in your script:

Load * Inline

[

     Customer, Sales

     A, 100

     B, 120

     C, 300

     D, 400

     E, 75

     F, 50

     G, 125

     H, 2000

     I, 250

];

View solution in original post

3 Replies
MK_QSL
MVP
MVP

Considering that you have customer and sales data and you want top 5 customers by sales

Create a Straight Table

Use Calculated Dimension

=IF(Aggr(Rank(SUM(Sales),4),Customer)<=5,Customer)

Expression

SUM(Sales)

Use Below in your script:

Load * Inline

[

     Customer, Sales

     A, 100

     B, 120

     C, 300

     D, 400

     E, 75

     F, 50

     G, 125

     H, 2000

     I, 250

];

MK_QSL
MVP
MVP

Another Way

Create a Straight Table

Dimension

Customer

Expression

SUM({<Customer = {"=Rank(SUM(Sales),4)<=5"}>}Sales)

balanandam
Creator II
Creator II

I did as suggested. But my problem now is, it is taking top 5 as 100% rather than whole, and dividing them as per the share.

ex:

I need each one of the exact share(%) in the whole sum i.e, SUM(Sales).

Br, Balanandam