I try to model your question using Superstore,
please find the attached workbook.
The key is to use nested table calculations.
The inner one would be WINDOW_SUM() over Success,
the outer one would be RANK_DENSE() over Success & Country.
That is for each Country the former calc would give the same result
(for both stacked Marks with either Success == Yes or Success == No, if any).
And with RANK_DENSE() Marks of the same Country would get equal Rank #.
Of course there would be a situation when some Countries would get the same Rank #
(as in the attached both Missouri and Oklahoma get the same Rank # of 26).
This is unavoidable, because RANK_UNIQUE() could not work in this case.
Thanks! I'll give that a try.