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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Need to calculate RANK

Hi,

I have a table that looks something like this:

CityNumeratorDenominator(Numerator/Denominator)*100
South London71258.30%
London415377.30%
East london505689.20%

I have the bar chart and it displays the percentage of each city

I need to calculate the RANK in a TEXT BOX for "LONDON"

It should look like

London - Rank - 2 in a TEXT BOX.

Please help me out. I am new and struggling with this.

Labels (1)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Anand,

Nice solution.  Two suggestions:

1. I think the set could be simple {<City='London'>}

2. To avoid rank like '2 - 5'0 when there are multiple Cities with the same amount, use num(rank(...))

=only({<City={'London'}>} aggr(num(rank(sum((Numerator/Denominator)*100))),City))

Regards,

Michael

View solution in original post

7 Replies
its_anandrjs
Champion III
Champion III

Write a script in expression like

Rank( Sum( (Numerator/Denominator)*100 ), 0, 1 )

HTH

Regards,

Anand

Not applicable
Author

I created a text box and wrote the expression you mentioned. It just says 1 in the TEXT BOX.

its_anandrjs
Champion III
Champion III

In a text box write this

=only({<City={"=rank(sum({<City={'London'}>}(Numerator/Denominator)*100))=1"}>}

aggr(rank(sum((Numerator/Denominator)*100)),City))

HTH

Regards,

Anand

Anonymous
Not applicable
Author

Anand,

Nice solution.  Two suggestions:

1. I think the set could be simple {<City='London'>}

2. To avoid rank like '2 - 5'0 when there are multiple Cities with the same amount, use num(rank(...))

=only({<City={'London'}>} aggr(num(rank(sum((Numerator/Denominator)*100))),City))

Regards,

Michael

Not applicable
Author

Sorry Anand. It doesnt work.  Just gives  as output

Not applicable
Author

Sorry Anand. It doesnt work.  Just gives a minus sign in the text box when I apply it. 

Not applicable
Author

Thanks Anand and Michael. I made some Changes and it worked.

The changes I have made was to add the MOde to the expression.