Forum Discussion
How to using SQL statement to create a new table base on two exiting tables?
- 9 years ago
Hi j_w
You can do this in a number of places. In Power BI you can create new tables using this button
And just paste in the following DAX for your example
Table 3 = EXCEPT('Table 1','Table 2') - 9 years ago
In Power Query you can simply merge (join) the tables with join type left anti (records in Table1 that don't exist in Table2).
This video illustrates how the code below is created.
let Source = Table.NestedJoin(Table1,{"ID1"},Table2,{"ID2"},"NewColumn",JoinKind.LeftAnti), #"Removed Columns" = Table.RemoveColumns(Source,{"NewColumn"}) in #"Removed Columns"
Hi j_w
You can do this in a number of places. In Power BI you can create new tables using this button
And just paste in the following DAX for your example
Table 3 = EXCEPT('Table 1','Table 2')
You can also do it in SQL but you will probably need a linked server between the two servers for the query to work.
There will also be a way you can do it in the Query Editor too MarcelBeug will probably give you the best approach.
- MarcelBeug9 years agoCommunity Champion
In Power Query you can simply merge (join) the tables with join type left anti (records in Table1 that don't exist in Table2).
This video illustrates how the code below is created.
let Source = Table.NestedJoin(Table1,{"ID1"},Table2,{"ID2"},"NewColumn",JoinKind.LeftAnti), #"Removed Columns" = Table.RemoveColumns(Source,{"NewColumn"}) in #"Removed Columns"