Very odd behavior with ISINSCOPE

Viewed 93

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.

enter image description here

Now, if I were to do an Expand All, I get the following:

enter image description here

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:

https://siestakeysoftware-my.sharepoint.com/:u:/g/personal/randyminder_siestakeysoftware_onmicrosoft_com/EfEJ-ap1VABHlZxwkgXoPZ4BBFrmMnmU5kLtk-LGaZL5yQ?e=Xv5J4r

0 Answers
Related