Forum Discussion

G4analytics's avatar
G4analytics
Regular Visitor
2 years ago
Solved

Power Bi Relationship

Hello Community,    Is there any option to filter 2 fact tables by 2 dimension tables? The 2 fact tables have a Date column. My problem is im trying to do it but cant avoid the reduntance window. ...
  • DataSkills's avatar
    DataSkills
    2 years ago

    I am still not all that clear on what you have done. A diagram of your relationships would be very helpful to understand what you are trying to explain. Why not take a screen shot of your relationship, and if possible, the unexpected results you are seeing?

     

    I am also not clear on why you mention the date columns. What have these got to do with the dimensions as it seems that you have related

    Dimension1.[ID] to FACT1.[Dim1ID] and FACT2.[Dim1ID] and...

    Dimension2.[ID] to FACT1.[Dim2ID] and FACT2.[Dim2ID].

     

    Where does the date field fit into all of this? 

     

    However, you say that "...I don't find a way to filter for both dimensions". Are you saying that your fact tables don't filter the dimension tables? That is "normal" behaviour for a 1 to many relationship with a single cross filter direction (the default type of relationship in Power BI). Generally we want dimension tables to filter fact tables, but not the other way around. 

     

    If you DO want the fact table to filter the dimension tables, you would need to change your cross filter direction to both. However, this can cause your model to be slower, and in more complex cases with multiple tables, can create ambiguity in your model. So, it's not generally desirable to do this. 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Thanks for the reply from vanessafvg and  DataSkills , please allow me to provide another insight:

    Hi, G4analytics 


    We think the main reason you have redundant data is because of a closed-loop relationship.
     

    That's why we recommend that multiple fact tables join a dimension table to form a star chart structure:

    I offer you two solutions:

    First, you can try to modify the two active relationships of dimkey1 and dimkey2 to join the fct2 table to inactive, and then use USERELATIONSHIP to activate the relationship:

     

    Here is a screenshot of the relevant documentation:


    USERELATIONSHIP function (DAX) - DAX | Microsoft Learn

    2.The second way is to copy dimkey1 and dimkey2 as dimkey11 and dimkey22 re-establish contact with fct1 and disconnect the original connection: dimkey1 and dimkey2 connect fct1.

    Here is the relevant documentation:
    Model relationships in Power BI Desktop - Power BI | Microsoft Learn
    Create and manage relationships in Power BI Desktop - Power BI | Microsoft Learn

    The above is my suggestion, you can try it according to your needs, hopefully back up your data before trying.Of course, if you have any new ideas, you are welcome to contact us.
     

    Best Regards,

    Leroy Lu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

  • G4analytics's avatar
    G4analytics
    2 years ago

    Thank you for all your answers, very helpful.