Forum Discussion
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 ??
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.
3 Replies
- mhossain
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.
- AnonymousNot applicable
- Anand24
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 !!!