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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
novicenew
New Member

Difference between Table1 and Table2

I have a 2 tables, both has the same column names col1, col2. Table1 has more data (1000) and Table2 has subset of Table1 (300). I am trying to get the rows into another table which are exists only in Table1.  I only want the difference, But I always get entire Table1 or Table2. 

let
Source1 = Table1,
Source2 = Table2,

DistinctTable1 = Table.Distinct(Table.SelectColumns(Source1, {"col1", "col2"})),
DistinctTable2 = Table.Distinct(Table.SelectColumns(Source2, {"col1", "col2"})),

Difference = Table.RemoveMatchingRows(DistinctTable1, Table.ToRecords(DistinctTable2), {"col1", "col2"})

in
Difference

 

What is the mistake I am doing? 

2 ACCEPTED SOLUTIONS
HotChilli
Community Champion
Community Champion

Merge the tables and use an Anti-join. It's all done in the Merge dialog

View solution in original post

novicenew
New Member

Below is the script. Had to remove a 3rd column which is being created. 
let
Source1 = Table1,
Source2 = Table2,
 
DistinctTable1 = Table.Distinct(Table.SelectColumns(Source1, {"col1", "col2"})),
DistinctTable2 = Table.Distinct(Table.SelectColumns(Source2, {"col1", "col2"})),
 
Difference = Table.NestedJoin(DistinctTable1, {"col1"}, DistinctTable2, {"col1"}, "DistinctTable2", JoinKind.LeftAnti)
#"Removed Columns" = Table.RemoveColumns(Difference,{"DistinctTable2"}),
in
Difference

View solution in original post

2 REPLIES 2
novicenew
New Member

Below is the script. Had to remove a 3rd column which is being created. 
let
Source1 = Table1,
Source2 = Table2,
 
DistinctTable1 = Table.Distinct(Table.SelectColumns(Source1, {"col1", "col2"})),
DistinctTable2 = Table.Distinct(Table.SelectColumns(Source2, {"col1", "col2"})),
 
Difference = Table.NestedJoin(DistinctTable1, {"col1"}, DistinctTable2, {"col1"}, "DistinctTable2", JoinKind.LeftAnti)
#"Removed Columns" = Table.RemoveColumns(Difference,{"DistinctTable2"}),
in
Difference
HotChilli
Community Champion
Community Champion

Merge the tables and use an Anti-join. It's all done in the Merge dialog

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.