Forum Discussion
Mederic
2 years agoPost Patron
Compare 2 tables
Hello, I'd like to compare 2 tables, each in a different tab. I would like to compare one by 2 criteria and another by all the columns. How can I do this with Power query? Thanks in advance ...
- 2 years ago
Mederic
2 years agoPost Patron
Hello
Anonymous , I've tested your code and it also works very well on this test file.
I just deleted the last step which removes the Duplicates and I get the expected result.
However, the code is very slow on my real file of more than 30,000 rows=>Table_1, more 6,000 rows=>Table_2 and I have to stop the process manually.
lbendlin , the Version 1 in the video is very fast and works very well
Here is the code used:
let
Source = Table.NestedJoin(Table_1, {"Code", "Qty"}, Table_2, {"Code", "Qty"}, "Table_2", JoinKind.Inner),
InnerJoin1 = Table.SelectColumns(Source,{"Code", "date", "Year", "Qty"}),
#"Added Custom" = Table.AddColumn(InnerJoin1, "Custom", each "Table_1"),
Custom1 = Table.NestedJoin(Table_2, {"Code", "Qty"}, Table_1, {"Code", "Qty"}, "Table_1", JoinKind.Inner),
InnerJoin2 = Table.SelectColumns(Custom1,{"Code", "date", "Year", "Qty"}),
#"Added Custom1" = Table.AddColumn(InnerJoin2, "Custom", each "Table_2"),
#"Full Inner Join" = Table.Combine({#"Added Custom", #"Added Custom1"}),
#"Sorted Rows" = Table.Sort(#"Full Inner Join",{{"Code", Order.Ascending}}),
#"Renamed Columns" = Table.RenameColumns(#"Sorted Rows",{{"Custom", "Source"}}),
#"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",{{"Source", type text}})
in
#"Changed Type"
Thank you 2 for your solutions
Have a nice evening
Best Regards