Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
yh2023
Contributor III
Contributor III

Ranking Based on District Counts within DoctorName Groups

Hey everyone,

I'm trying to create a ranking based on the count of each District within individual DoctorName groups. Here's a sample table structure:

DoctorName | District | Count
A1 | Hyd | 21
A1 | Karm | 20
A1 | Goa | 70
A2 | Hyd1 | 45
A2 | Karm1 | 69
A2 | Goa | 1

I'm using the Rank function to generate the ranking based on the count of each District within each DoctorName group, ordered by decreasing count.

I want the output column to be
DoctorName | District | Count | Output
A1 | Hyd | 21 | 2
A1 | Karm | 20 | 3
A1 | Goa | 70 | 1
A2 | Hyd1 | 45 | 2
A2 | Karm1 | 69 | 1
A2 | Goa | 1 | 3

I tried - 
=aggr(Rank(total sum(Count), 1, 1), DoctorName, District)

But this gives the output as - 
DoctorName | District | Count | Output
A1 | Hyd | 21 | 4
A1 | Karm | 20 | 5
A1 | Goa | 70 | 1
A2 | Hyd1 | 45 | 3
A2 | Karm1 | 69 | 2
A2 | Goa | 1 | 6

Any insights or suggestions on how to refine this approach or achieve the desired output would be greatly appreciated!

Labels (3)
1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

just try either of the below

 

=Rank(sum(measure), 4, 1)

OR

=aggr( Rank(sum(measure), 4, 1), DoctorName, District)

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

8 Replies
Anil_Babu_Samineni

@yh2023  Let's focus 

DoctorName | District | Count | Output
A1 | Hyd | 21 | 2
A1 | Karm | 20 | 3
A1 | Goa | 70 | 1
A1 | Hyd1 | 45 | 2
A1 | Karm1 | 69 | 1
A1 | Goa | 1 | 3

 

what logic this should be 1 for bold? Can you explain? Why you are repeasting same Rank 2 times?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
yh2023
Contributor III
Contributor III
Author

@Anil_Babu_Samineni 

I appreciate the clarification; it should be A2.

DoctorName | District | Count | Output
A1 | Hyd | 21 | 2
A1 | Karm | 20 | 3
A1 | Goa | 70 | 1
A2 | Hyd1 | 45 | 2
A2 | Karm1 | 69 | 1
A2 | Goa | 1 | 3

Now, I'm looking to generate rankings based on the 'Count,' but I want a distinct ranking for each 'District' within every 'DoctorName' group.

Parthiban
Creator
Creator

Hi,

Try this one

=Rank(sum(Count))

 

This will work prefectly.

Ahidhar
Creator III
Creator III

try this in script

tab:
load * inline
[
DoctorName | District | Count
A1 | Hyd | 21
A1 | Karm | 20
A1 | Goa | 70
A2 | Hyd1 | 45
A2 | Karm1 | 69
A2 | Goa | 1
]
(delimiter is '|');

NoConcatenate
tab1:
load *,
autonumber(Count,DoctorName) as Output
resident tab order by DoctorName,Count desc;
drop table tab;

Ahidhar_0-1704951024829.png

 

yh2023
Contributor III
Contributor III
Author

It works thank you! Is it possible to achieve this in Chart Expressions?

vinieme12
Champion III
Champion III

just try either of the below

 

=Rank(sum(measure), 4, 1)

OR

=aggr( Rank(sum(measure), 4, 1), DoctorName, District)

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
Anil_Babu_Samineni

@yh2023 This should work.

=Aggr(Rank(Sum(Count),District),DoctorName, District)

Anil_Babu_Samineni_0-1704954653416.png

 

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
yh2023
Contributor III
Contributor III
Author

Great it works Thank you!

yh2023_2-1704954927946.png