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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Rank

Need assistance in terms to develop a pivot table with Rank function:

Requirement:

We have a map where we are plotting Rank City wise based on Score.

If a particular user click on a specific city, a pivot table will be shown with the rank of the selected city in comparision to the rest of cities

Data is as follows:

   

YearCityLevel1Level2Level3Level4Score
2015ABCEnbPE & SEPEQ184.62
2015ABCEnbPE & SEPEQ290.35
2015ABCEnbPE & SEPEQ380.00
2015ABCEnbPE & SEEGQ458.82
2015ABCEnbPE & SEEGQ561.21
2015ABCEnbPE & SEEGQ683.07
2015PQREnbPE & SEPEQ134.62
2015PQREnbPE & SEPEQ235.74
2015PQREnbPE & SEPEQ390.00
2015PQREnbPE & SEEGQ460.00
2015PQREnbPE & SEEGQ580.00
2015PQREnbPE & SEEGQ665.00

 

 

Complete Pivot table output:

   

CityLevel1Level2Level3Level4ScoreRank
ABCEnb 76.341
PE & SE 76.341
PE 84.991
Q184.621
Q290.351
Q380.002
EG 67.702
Q458.822
Q561.212
Q683.072
PQREnb 60.891
PE & SE 60.892
PE 53.452
Q134.622
Q235.742
Q390.001
EG 68.331
Q460.001
Q580.001
Q665.001

Final pivot table would show only 1 city at a time i.e based upon the user selection in the map Eg.if City 'ABC' selected follwoing would be the output:

   

CityLevel1Level2Level3Level4ScoreRank
ABCEnb 76.341
PE & SE 76.341
PE 84.991
Q184.621
Q290.351
Q380.002
EG 67.702
Q458.822
Q561.212
Q683.072

I hope I was clear in explaining my query.

Thanks in advance

1 Solution

Accepted Solutions
sunny_talwar

Try this:

Pick(Dimensionality()-1,

Aggr(NODISTINCT Rank(Sum({<City>}Score)), Level1, City),

Aggr(NODISTINCT Rank(Sum({<City>}Score)), Level2, City),

Aggr(NODISTINCT Rank(Sum({<City>}Score)), Level3, City),

Aggr(NODISTINCT Rank(Sum({<City>}Score)), Level4, City))

View solution in original post

26 Replies
Not applicable
Author

Use the below expression

Aggr(Rank(Sum(Score)),City)

Not applicable
Author

Dear Umamaheswara,

When i try Aggr(Rank(Avg(Scores)),City).It doesnot yield the desired answer.

I even tired Aggr(Rank(Avg(Scores)),City,Level4). It also doesnot yeild the desired answer

sunny_talwar

How about this?

Aggr(NODISTINCT Rank(Sum(Score)), Level3)

or

Aggr(NODISTINCT Rank(Sum(Score)), Level3, City)

sunny_talwar

Can't really focus, but may be City might come before Level3

Aggr(NODISTINCT Rank(Sum(Score)), City, Level3)

Not applicable
Author

Dear Sunny,

=Aggr(NODISTINCT Rank(Avg(Score2)),Level4,City2)  worked for me as below

However there is one issue when we collapse the pivot, the ranks become null

sunny_talwar

Would you be able to share your qvw for us to play around with?

Not applicable
Author

Hi Hitesh - If you are using HRank(), drag the last dimension to make it horizontal. For an instance, once you create the pivot table, drag level 4 as horizontal dimension.

pivot.png

Not applicable
Author

PFA

sunny_talwar

See how Level3 = EG is made up of both 2 and 1, what would you want to see when collapsed? 2 or 1?

Capture.PNG