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 lbendlin ,
Thank you for your message,
For version 1, I went through 2 queries and I get an acceptable but not very elegant result,
For version 2, I used Intersect and got a decent result.
Finally, for the version 2, it doesn't make sense to have duplicates. One row is enough for me.
Any other solution is welcome
Thanks in advance
Best Regards
Result V1 :
Query 1 :
let
Source = Table.Combine({Table_1, Table_2})
in
Source
Query 2 :
let
Source = Table.NestedJoin(Query2, {"Code", "Qty"}, Query1, {"Code", "Qty"}, "Query1", JoinKind.LeftAnti),
#"Removed Columns" = Table.RemoveColumns(Source,{"Query1"}),
#"Sorted Rows" = Table.Sort(#"Removed Columns",{{"Code", Order.Ascending}})
in
#"Sorted Rows"
Result V2 :
let
Source = Table.FromRecords(List.Intersect({Table.ToRecords(Table_1), Table.ToRecords(Table_2)})),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"date", type date}})
in
#"Changed Type"
lbendlin
2 years agoSuper User
Apologies, I gave the wrong advice based on DAX. But it looks like you found the Power Query solutions yourself. What exactly do you still need help with?