Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Rank function in qlik sense

Hi,

If I have to display the rank on the basis of amount and alphabetically,then what would be the syntax for the same. could anyone please help me out?

name                    amount

piyush chawla        100

piyush singh           100

raj arora                  50

raj singh                 50

Then the rank should be

name                    amount     rank

piyush singh            100          2

piyush chawla          100          1

raj arora                  50            3

raj singh                 50            4

1 Solution

Accepted Solutions
sunny_talwar

Script:

Table:

LOAD * Inline [

name,              amount

piyush chawla,      100

piyush singh,      100

raj arora,          50

raj singh,          50

];

FinalTable:

LOAD name,

  amount,

  RowNo() as Rank

Resident Table

Order By amount desc, name;

DROP Table Table;

View solution in original post

5 Replies
sunny_talwar

You can try doing this in the script if the rank doesn't have to be dynamic based on selection?

sunny_talwar

Script:

Table:

LOAD * Inline [

name,              amount

piyush chawla,      100

piyush singh,      100

raj arora,          50

raj singh,          50

];

FinalTable:

LOAD name,

  amount,

  RowNo() as Rank

Resident Table

Order By amount desc, name;

DROP Table Table;

Anonymous
Not applicable
Author

Hi Aanchal,

Maybe try in UI:

=Aggr(Rank(Sum(Amount), Name,Amount)

jonathandienst
Partner - Champion III
Partner - Champion III

You will need to calculate some sort of score which includes the amount and the alphabetic ranking of the name. you could do this by making a composite during the load:

     num(amount, '000000') & left(name  & '                    ', 20) as rankscore,

and then rank the rankscore values in the front end or in the load script.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
JonnyPoole
Former Employee
Former Employee

Does this work ?  In the SORT i am sorting in order by:

sum(Amount) -> sort numerically -> descending

name -> sort alphabetically -> ascending

Capture.PNG