Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Rank by group

Hi,

I have an excel sheet with two columns e.g.

IDRATING
1-20
150
1-1
10
2100
2-15
2

98

I want to return the top rank by ID so ID 1 would return 50, ID 2 100 etc.

any ideas how to code this as a calculated dimension?

Thanks

1 Solution

Accepted Solutions
Not applicable
Author

Hi Coran

If you have the ID and rating as column 1 and column 2, then the expression

=rank(rating)

will automatically be grouped by ID - but it must be sorted by ID (or the group name)

Does this work for you?

Regards,

Erica

View solution in original post

10 Replies
Clever_Anjos
Employee
Employee

maybe aggr(Max(RATING),ID)

Anonymous
Not applicable
Author

Try expression

max(total<ID> Rating)

Edit: attached

Not applicable
Author

What about returning the top 2 Ratings?

Clever_Anjos
Employee
Employee

max(total<ID> Rating, 1) and max(total<ID> Rating, 2)

Not applicable
Author

I actually need the rank number to be returned.

e.g.

I want to return the rank number based on max rating grouped by ID so ID 1 would return the following:

50  rank 1

-20 rank 2

etc.

I think I need to use the aggr and rank function in a calculated dimension but I can't seem to get the syntax correct.

Thanks guys

Not applicable
Author

Hi Coran

If you have the ID and rating as column 1 and column 2, then the expression

=rank(rating)

will automatically be grouped by ID - but it must be sorted by ID (or the group name)

Does this work for you?

Regards,

Erica

tresesco
MVP
MVP

Try:

=Aggr(If( Rank(Rating)<3, Rating),ID, Rating)                      // as calculated dimension

PFA

VishalWaghole
Specialist II
Specialist II

Hi,

PFA

Hope it will help you.

Thanks and Regards,

Vishal Waghole

Anonymous
Not applicable
Author

perfect