Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

woshua5550
Contributor III

Get rank in textbox

Hello experts

I need a expression in a textbox which will show current selected city's rank

plz have a look at the sample data below

CityAmount
Beijing100
Shanghai500
Beijing200
Chongqing150

when I select "Beijing" it should return "2" , when I select "Shanghai" it should return "1" ,"Chongqing" is "3"

I don't  want to deal with it during data loading,plz give me the frontend solution

thanks

1 Solution

Accepted Solutions
MVP
MVP

Re: Get rank in textbox

Try like:

=Aggr(rank(Sum({<City>}Amount)),City)

5 Replies
MVP
MVP

Re: Get rank in textbox

Try like:

=Aggr(rank(Sum({<City>}Amount)),City)

Highlighted
woshua5550
Contributor III

Re: Get rank in textbox

Thanks Bro! It works

but how should I change this expression if I use alternate states on city filter ?

let's say I have city in a list box with Alternate States "G1" and  textbox with default states

I tried "=Aggr(rank(Sum({G1<City>}Amount)),City)" but it doesn't work

plz help , thank you

pooja_prabhu_n
Contributor III

Re: Get rank in textbox

Try like this in text box

=aggr(rank(sum( {1<city=>}  Amount)),city)

Re: Get rank in textbox

Try this may be

=Only({G1} Aggr(Rank(Sum({<City>} Amount)), City))

woshua5550
Contributor III

Re: Get rank in textbox

Excellent ! Thank you Sunny!