Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
UsePowerBI
Post Prodigy
Post Prodigy

Help with joining tables

Hello

 

I would like to join two tables using different field matching combinations so that if one matching does not return a result, the other matching is used.

 

Is that possible?

 

E.g. I want to join Table1 with Table2 by matching Field1ofTable1 with Field1ofTable2 but if there is no match in a specific row, I want to perform a matching between Field2ofTable1 and Field2ofTable2. So basically, I want two lines that join two tables in the Manage Relationships which both should be active.

 

Thanks!

3 REPLIES 3
amitchandak
Super User
Super User

@UsePowerBI , if you want both of them to join, you can use the concatenated column in both tables and join

 

key = [Field1] & "-" [Field2]

 

and join on key.

If you do different relation you can create active inactive relation and use userelation

https://radacad.com/userelationship-or-role-playing-dimension-dealing-with-inactive-relationships-in...

 

mhossain
Solution Sage
Solution Sage

@UsePowerBI 

 

I think in manage relatiohship/model tab you can't do that. But obviously you want to use these relationship to calculate something and drag to table/visual, so would suggest you create virtual relationship in the measure with condition.

You can use TREATAS dax.

 

Please let me know if above helps or explain more what is your objective behind this.

lkalawski
Memorable Member
Memorable Member

Hi @UsePowerBI

 

You can create a measure which dynamically change the relationships.
Please check this:
 https://www.sqlbi.com/articles/using-userelationship-in-dax/

 

_______________
If I helped, please accept the solution and give kudos! 😀 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.