Would you be opposed ordering the set inside the rank function? This makes it a bit easier because it keeps the current context in play for the outside dimension (the one you want to "partition" on).
Here's an example where the months of each year are sorted and ranked by sales amount. The ranking is "partitioned" by year.
WITH
SET [YearMonthSet] AS
GENERATE(
[Date].[Calendar Year].[Calendar Year],
ORDER(
CROSSJOIN (
[Date].[Calendar Year].CurrentMember
,[Date].[Month of Year].[Month of Year]
)
,[Measures].[Internet Sales Amount]
,DESC
)
)
MEMBER [Measures].[Rank in Year] AS
RANK(
[Date].[Month of Year].CurrentMember
,ORDER (
[Date].[Month of Year].[Month of Year]
,([Date].[Calendar Year].CurrentMember,[Measures].[Internet Sales Amount])
,DESC
)
)
SELECT
{
[Measures].[Internet Sales Amount],
[Measures].[Rank in Year]
} ON 0,
{
[YearMonthSet]
} ON 1
FROM
[Adventure Works]
The calculated set isn't necessary but just makes the result set pretty:

BI Developer and lover of data (Blog |
Twitter)