Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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;
You can try doing this in the script if the rank doesn't have to be dynamic based on selection?
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;
Hi Aanchal,
Maybe try in UI:
=Aggr(Rank(Sum(Amount), Name,Amount)
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.
Does this work ? In the SORT i am sorting in order by:
sum(Amount) -> sort numerically -> descending
name -> sort alphabetically -> ascending