Hi all
I have a lot of tables that I merge back and forth in Power Query and in general, I need to merge LeftOuter, but as the table I merge with often has duplicates, I use fuzzy matching, with only 1 result (as I always only need the first occurrence).
But I have just noticed a quite troubling issue with Power Query merging, when I do as above, as it seems to merge completely incorrect sometimes.
I have set up a small test sheet, with 2 tables with numbers (but treated as text) - table2 has a single duplicate (the last 2 records). As seen below, when I merge table2 into table 1, and then check if the merged result corresponds with the source result, a bunch of rows are incorrectly merged:
WrongMerging.png
This is my merging code:
Is this a bug or am I doing something wrong - and what is the correct way of doing this kind of merge in Power Query?![]()
let Source = Excel.CurrentWorkbook(){[Name="Table5"]}[Content], #"Changed Type" = Table.TransformColumnTypes(Source,{{"Numbers1", type text}}), #"Merged Queries" = Table.FuzzyNestedJoin(#"Changed Type", {"Numbers1"}, Numbers2Table, {"Numbers2"}, "Numbers2Merging", JoinKind.LeftOuter, [IgnoreCase=false, IgnoreSpace=false, NumberOfMatches=1]), #"Expanded Numbers2" = Table.ExpandTableColumn(#"Merged Queries", "Numbers2Merging", {"Numbers2", "Occurrence"}, {"Numbers2Merged", "Occurrence"}), #"Added Conditional Column" = Table.AddColumn(#"Expanded Numbers2", "WrongMerge", each if [Numbers1] <> [Numbers2Merged] and [Numbers2Merged] <> null then "WrongMerge" else null) in #"Added Conditional Column"
Best regards
Imbizile
Bookmarks