PDA

View Full Version : PQ-compare two columns A and B in the same table then return unmatched



sandy666
07-10-2023, 02:23 PM
SourceResult

ColumnAColumnBData1Data2ColumnANotMatchBData1Data2

USNTSUSNTSABC
123USNTSUSSPZABC
123

USNTSUSSPZABC
123USNTSUSLVVABC
123

USNTSUSLVVABC
123USNTSUSLVVABC
123

USNTSUSLVVABC
123USNTSUSLVVABC
123

USNTSUSLVVABC
123USNTSUSLVVABC
123

USNTSUSLVVABC
123USNTSUSLVVABC
123

USNTSUSLVVABC
123USNTSUSLVVABC
123

USNTSUSLVVABC
123USNTSUSLVVABC
123

USNTSUSLVVABC
123USNTSUSLVVABC
123

USNTSUSLVVABC
123USLVVUSNYCABC
123

USMSYUSMSYABC
123

USHOUUSHOUABC
123

USMSYUSMSYABC
123

USMSYUSMSYABC
123

USLVVUSNYCABC
123

USNYCUSNYCABC
123



// Table1
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
Diff = Table.AddColumn(Source, "NotMatchB", each List.Difference({[ColumnB]},{[ColumnA]})),
Expand = Table.ExpandListColumn(Diff, "NotMatchB"),
Filter = Table.SelectRows(Expand, each ([NotMatchB] <> null)),
TSC = Table.SelectColumns(Filter,{"ColumnA", "NotMatchB", "Data1", "Data2"})
in
TSC