I am using the Contoso database and I have a very simple matrix that ranks product category and subcategories. It looks as follows when fully collapsed. You can see the sales rank value for each category is correct when fully collapsed.
Now, if I were to do an Expand All, I get the following:
Notice that each of the category ranks increased by 1. For example, Home Appliances went from 1 to 2. All the subcategory ranks are correct. If I were to do another Collapse All, the category ranks return to being correct.
Here is my measure for calculating the sales ranks:
Sales Rank =
IF (
ISINSCOPE(Products[SubCategory]),
RANKX(
All(Products[SubCategory]),
[Sales Amount]
),
IF (
ISINSCOPE(Products[Category]),
RANKX(
ALL(Products[Category]),
[Sales Amount]
)
)
)
Here is the Sales Amount measure:
Sales Amount =
SUMX(
'Online Sales',
'Online Sales'[Sales Quantity] * 'Online Sales'[Unit Price] - 'Online Sales'[Discount Amount]
)
I'm almost tempted to think this is a bug in Power BI, but it's probably something wrong with my measure.
If you are interested you can download the PBIX file I'm working with here:

