Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to get rank positions

Hi everybody!

I have a question regarding ranking. I have a table with sales volume by agents.

Screenshot at мая 07 16-15-40.png

I need to get following table when I chose particular agent. Depending on how much agent has sold he get rank in context of each city:

For example if I chose Adam I will get:

Screenshot at мая 07 16-11-26.png

Regards Alex

1 Solution

Accepted Solutions
tamilarasu
Champion
Champion

Hi Alex,

You can check below expression.

If(GetSelectedCount(Agent)>0,Aggr(Rank(Sum({1}Sales)),City,Agent),Rank(Sum(Sales)))

If agent is not selected, then rank will be calculated based on the sales of the each city.

If this is not your expected expression, please post an another sample with expected output.

View solution in original post

7 Replies
tamilarasu
Champion
Champion

Hi Alex,

You can try below expression in straight / pivot table.

Rank(Aggr(Sum(Sales),City))

If suppose the sales value is same for two cities (For example New York 1000 and Chicago 1000), then the above expression will show the rank like 2-3 or 1-2.

Untitled.png

If you want to assign a distinct rank for each city, you need  to use below expression.


Num(Rank(Aggr(Sum(Sales),City),4))

Untitled1.png

Not applicable
Author

Hi Tamil, thanks for response

I tried but this formula doesn't consider other agent - we get only which city is one which is second for this agent, but I need that formula calculate rating through all agent for each city and put result for selected agent.

Please ask if I was unclear.

Regards Alex

swuehl
MVP
MVP

You can create a straight table chart with dimension City and expression

=If(Sum(Sales)+Sum({1}0)>0,Rank(Sum(Sales)),'-')

2016-05-07 22_52_08-QlikView x64 - [C__Users_Stefan_Downloads_comm215981.qvw_].png

tamilarasu
Champion
Champion

Hi Alex,

You can check below expression.

If(GetSelectedCount(Agent)>0,Aggr(Rank(Sum({1}Sales)),City,Agent),Rank(Sum(Sales)))

If agent is not selected, then rank will be calculated based on the sales of the each city.

If this is not your expected expression, please post an another sample with expected output.

Not applicable
Author

Your solution works!

Thank you very much Tamil.

tamilarasu
Champion
Champion

Alex,

If you want to show hyphen for the countries which has no sales for the selected agent, you can use below expression.

If(GetSelectedCount(Agent)>0, If(Sum({1}Sales)>0,  Aggr(Rank(Sum({1}Sales)), City, Agent), '-'), Rank(Sum(Sales))) 

Have a nice day.

Not applicable
Author

yes, I got it,

Thanks again,

Alex