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

Announcements
Streamlining user types in Qlik Cloud capacity-based subscriptions: Read the Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Ranjanac
Contributor III
Contributor III

Rank()

On what basis, we can use Rank() function to Show Top 3 customer name which is having highest Revenue.

and, how to write this expression ?

Customer ID

Customer Name

Location

SalesPerson Name

SalesPerson City

Revenue

Profit

101

Elon

America

Elon

Newyork

10000

500

102

Mukesh

India

Sundar

Newyork

40000

200

103

Jeff

America

Mukesh

Mumbai

70000

300

104

Sundar

America

Narendar

Delhi

80000

700

105

Jack

China

Vijay

Hyderabad

500000

900

106

Steve

America

Amit

Kolkata

20000

600

106

Tim

America

Jayanth

Bhuvaneshwar

100000

500

107

Larry

America

Tony

London

350000

300

108

Indira

India

Peter

Dubai

150000

900

 

Labels (5)
7 Solutions

Accepted Solutions
Benoit_C
Support
Support

Hi @Ranjanac,

In order to show the top 3 customer names with the highest revenue, you can follow these steps:
 

- Create a measure called "total revenue for each customer" that calculates the total revenue for each customer. You can do this using the Sum() function:
  Sum(Revenue)
 

- Create a chart or table visualization in your app where you want to display the top 3 customer names.
 

- Apply a dimension limit to the visualization to show only the top 3 ranks. You can do this by going to the "Dimension" tab of the Customer Name colomn properties and setting the "Limitation" to "Fixed number" and "Top".
 

Regards,
Benoit


View solution in original post

simsa
Contributor III
Contributor III

In which chart are you trying to do this?

In Benoit's response above, you can put limit 3, and uncheck 'Show others' to display just the top 3.

And regarding the rank() function, I generally use it to color bars according to the measure

if(RANK(SUM(Revenue))<=3,'red','blue') (In the color by expression option)

simsa_0-1688659691154.png

 

View solution in original post

simsa
Contributor III
Contributor III

Alternately,

Put dimension as:  if(aggr(rank(SUM(Revenue)), [Customer Name]) <=3 , [Customer Name])

And exclude null values, Hope it helps

View solution in original post

Ranjanac
Contributor III
Contributor III
Author

Yes, Thanks a lot 🙂

View solution in original post

Ranjanac
Contributor III
Contributor III
Author

Thanks a lot 🙂

View solution in original post

sidhiq91
Specialist II
Specialist II

@Ranjanac  You can also use below expression in your Dimension:

Aggr(if(Rank(Sum(Revenue))<=3,[Customer Name],null()),[Customer Name])

View solution in original post

Ranjanac
Contributor III
Contributor III
Author

7 Replies
Benoit_C
Support
Support

Hi @Ranjanac,

In order to show the top 3 customer names with the highest revenue, you can follow these steps:
 

- Create a measure called "total revenue for each customer" that calculates the total revenue for each customer. You can do this using the Sum() function:
  Sum(Revenue)
 

- Create a chart or table visualization in your app where you want to display the top 3 customer names.
 

- Apply a dimension limit to the visualization to show only the top 3 ranks. You can do this by going to the "Dimension" tab of the Customer Name colomn properties and setting the "Limitation" to "Fixed number" and "Top".
 

Regards,
Benoit


simsa
Contributor III
Contributor III

In which chart are you trying to do this?

In Benoit's response above, you can put limit 3, and uncheck 'Show others' to display just the top 3.

And regarding the rank() function, I generally use it to color bars according to the measure

if(RANK(SUM(Revenue))<=3,'red','blue') (In the color by expression option)

simsa_0-1688659691154.png

 

simsa
Contributor III
Contributor III

Alternately,

Put dimension as:  if(aggr(rank(SUM(Revenue)), [Customer Name]) <=3 , [Customer Name])

And exclude null values, Hope it helps

Ranjanac
Contributor III
Contributor III
Author

Yes, Thanks a lot 🙂

Ranjanac
Contributor III
Contributor III
Author

Thanks a lot 🙂

sidhiq91
Specialist II
Specialist II

@Ranjanac  You can also use below expression in your Dimension:

Aggr(if(Rank(Sum(Revenue))<=3,[Customer Name],null()),[Customer Name])

Ranjanac
Contributor III
Contributor III
Author

Thanks 🙂