Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Power BI - ambiguous relationships

Hi everyone, Let's suppose I have my only fact table (Sales) which is directly connected to the table Order . Then this table Order is divided into 2 exclusive "paths":  the one for the orders mad...
  • edhans's avatar
    edhans
    6 years ago

    Yes, you can do just about anything with an inactive relationship you can with an active relationship when it comes to measures. You just have to use CALCULATE or CALCULATETABLE to get there.

     

     

    USERELATIONSHIP Measure = 
    CALCULATE(
        MAX(Data[Name]),
        USERELATIONSHIP(Data[Field],'Table'[Field])
    )

     

    That is based on this model:

     

    And returns this result:

     

    MAX() is a way to convert a column to a scalar value that measures require. You could use VALUES() too if you 100% knew you'd only get one result.

     

    I did see your model. Your issue is your SalesPerson table is 1 to many to your Storeor... table, and also 1 to the Store table. There is no way for DAX to know truly what to do or which path to take if you go from Store to Storeor... (the name was truncated 🙂

    By using USERELATIONSHIP it tells it exactly how to behave and it ignores the other stuff.

     

    Make sense?

     

    As a side note, you can use LOOKUPVALUE() to get to unrelated tables. You can read through this thread this morning on how to do it. With or without a relationship, LOOKUPVALUE() will work though it is a pretty inefficent tool to use, but depends on the model size. As noted in my sig, I prefer to model in Power Query which is designed for this, and let DAX analyze data vs constructing tables and data. But it is always use the right tool for the job, and I am viewing your job through a peephole and don't understand the overall project.