I was trying to solve this same problem and created a script that I could attach to my toolbar. Since there wasn't a single formula that can be easily applied, this script will manually assign the proper ranking to the current data table after it prompts the user for the relevant columns. Feel free to use or adapt if desired.
dt1 = Current Data Table();
nw = New Window( "Select Columns",
<<modal,
Text Box( "Select the Column you want to Rank by:" ),
selectRankBy = Col List Box(
all,
width( 250 ),
maxSelected( 1 )
),
Text Box( "Select the Column you want to Group by:" ),
selectGroupBy = Col List Box(
all,
width( 250 ),
maxSelected( 1 )
),
Text Box( "Input the Name of the new Column" ),
newNameBox = Text Edit Box( "New Column Name")
);
rankCol = Column( dt1, selectRankBy << Get Selected);
groupCol = Column( dt1, selectGroupBy << Get Selected);
newColName = newNameBox << Get Text;
allColumnNames = dt1 << Get Column Names( String );
If( Contains( allColumnNames, newColName ) == 0,
newCol = dt1 << New Column( newColName,
Numeric,
Continuous,
Format( "Best", 10 ),
<<Set Each Value( Empty() )
),
Column( newColName ) << Set Each Value( Empty() );
newCol = Column( newColName );
);
groupType = groupCol << Get Data Type;
uniqueGroups = Associative Array( groupCol << GetValues ) << GetKeys;
For( i = 1, i <= Length( uniqueGroups ), i++,
If( groupType == "Character",
Eval(
Parse(
"groupRows = dt1<< Get Rows Where(:" || (groupCol << Get Name())|| " ==\!"" || Char( uniqueGroups[i] ) || "\!")"
)
),
Eval(
Parse(
"groupRows = dt1<< Get Rows Where(:" || (groupCol << Get Name()) || " =="|| Char( uniqueGroups[i] ) || ")"
)
)
);
rowRankList = As List( Ranking( rankCol[groupRows] ) );
For( j = 1, j <= Length( rowRankList ), j++,
newCol[groupRows[j]] = rowRankList[j];
);
);