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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
MostafaGamal
Helper V
Helper V

How to make a relation between 2 tables

Hi all, 

I have 2 different table i want to make a relation between 2 columns in those table but when i use to create a relation between those table it didnt work properly as some values in the first column is not existing in the second column 

i want to use those coulmn in a slicer

how to do that ?? 

1 ACCEPTED SOLUTION
mhossain
Solution Sage
Solution Sage

Hi @MostafaGamal 

 

So you have two tables, table1 and table2 and assuming 'ID' is the column for relationship, please follow below steps.

 

-- create a third table 'Table3' using dax, go to 'Modeling' in the toolbar -->'New Table' and write below dax

Table3 = DISTINCT( UNION(SELECTCOLUMNS(Table1,"ID",Table1[ID]),SELECTCOLUMNS(Table2,"ID",Table2[ID])))

 

-- Now you have Table3 with all the records from both Table1 and Table2 for that ID column.

--Create relationship Table3 to Table1 and Table3 to Table2.

 

Hope above makes sense, let me know if it helps.

View solution in original post

3 REPLIES 3
Anand24
Super User
Super User

Hi @MostafaGamal,

 

Can you attach some pictures with table details.

 

Moreover, even if some values from column1 from table 1 are not present in joining column 1 from table 2, a join should still take place.

Now this depends on what type of join you require. You can join on any join type using merge queries option from power query editor.

 

Give a thumbs up if this post helped you in any way and mark this post as solution if it solved your query !!!

 
mhossain
Solution Sage
Solution Sage

Hi @MostafaGamal 

 

So you have two tables, table1 and table2 and assuming 'ID' is the column for relationship, please follow below steps.

 

-- create a third table 'Table3' using dax, go to 'Modeling' in the toolbar -->'New Table' and write below dax

Table3 = DISTINCT( UNION(SELECTCOLUMNS(Table1,"ID",Table1[ID]),SELECTCOLUMNS(Table2,"ID",Table2[ID])))

 

-- Now you have Table3 with all the records from both Table1 and Table2 for that ID column.

--Create relationship Table3 to Table1 and Table3 to Table2.

 

Hope above makes sense, let me know if it helps.

pranit828
Community Champion
Community Champion

Hi @MostafaGamal

 

Check the below link.

https://docs.microsoft.com/en-us/dax/relatedtable-function-dax

https://databear.com/dax-related-table-functions/

 

https://www.youtube.com/watch?v=IQ25ATvJBoM&vl=en





PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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