Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Outer Join between Dimension tables bypass fact table

I have this model and I want to find out the assets without a maintenance plan. So I defined an inactive relationship between Asset and Maintenance Plan tables. I, then, defined this column and it sh...
  • AlbertoFerrari's avatar
    AlbertoFerrari
    8 years ago

    If you activate the inactive relationship, then there will be two paths from Asset to the PM fact table: one direct and one through the maintenance plan. As such, the model will be ambiguous and Power BI does not work with ambiguous models. One of the other relationships need to be deactivated to perform any calculation.

     

    The engine cannot deactivate the one you are activating with USERELATIONSHIP and it will not deactivate the direct one. Instead, most likely, it will deactivate the relationship between Maintenance plan and the PM table. As such, any filter applied to the Asset will filter the fact table with the direct relationship, vanishing your goal of using the maintenance plan as a bridge.

    Instead, you can move the filter manually using TREATAS like in this code:

     

    FilterMaintenanceByPlan :=
    CALCULATE ( 
         ...,
        TRETAS (
            VALUES ( Asset[AssetKey] ),
             MaintenancePlan[AssetKey]
        )
    )

    Nevertheless, if every maintenanceplan has an asset key, then it would be much better to model everything iwth a simpler snowflake, where the rel between maintenanceplan and asset is always active and you kill the rel between asset and the PM fact table. 

     

     

    The thing is: when you create a relationship between two dimensions, this is a clear signal that the model is the wrong one, and you need to revisit it trying to make it a star schema. 

     


    Have fun with DAX!

    Alberto Ferrari
    http://www.sqlbi.com