Power Query Fuzzy Lookup across one row

sauzee

New Member
Joined
Aug 24, 2017
Messages
22
Office Version
  1. 365
Platform
  1. Windows
Hi All

I'm trying to get all fuzzy lookups within a row to help with analysis. This thread has proved very helpful


But I'm struggling to exactly implement the solution. I have attached a much smaller version of the table and my current code up to the merge and fuzzy match is below. Many thanks!

Power Query:
let
    Source = Excel.CurrentWorkbook(),
    Table1 = Source{[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Table1,{{"Name1", type text}, {"Count1", type text}}),
    #"Merged Queries" = Table.FuzzyNestedJoin(#"Changed Type", {"Name1"}, #"Changed Type", {"Name1"}, "Changed Type", JoinKind.LeftOuter, [IgnoreCase=true, IgnoreSpace=true, Threshold=0.85, SimilarityColumnName="Similarity"]),
    #"Renamed Columns" = Table.RenameColumns(#"Merged Queries",{{"Changed Type", "Table"}})
in
    #"Renamed Columns"
 

Attachments

  • Screenshot 2022-10-21 122601.png
    Screenshot 2022-10-21 122601.png
    23.3 KB · Views: 33
OK lets see how we go with this.

1) Load your Table1 as a connection only query and in the right hand pane give it the name "Table1_2nd_Load" (without the quotes)
(that name is used in the code below)

2.1) Now either load the same table to Power Query again OR create a blank query.
2.2) Open the Advanced Editor of this query and replace everything you see there with the code below.
2.3) Close and Load To (select where to load it to, ideally give the query a meaningful name first)

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name1", type text}, {"Count1", Int64.Type}}),
    #"Merged Queries" = Table.FuzzyNestedJoin(#"Changed Type", {"Name1"}, Table1_2nd_Load, {"Name1"}, "Table1_2nd_Load", JoinKind.LeftOuter, [IgnoreCase=true, IgnoreSpace=true, Threshold=0.80]),
    AddCustomColAsList = Table.AddColumn(#"Merged Queries", "Name Match", each List.Sort([Table1_2nd_Load][Name1])),
    #"Removed Columns" = Table.RemoveColumns(AddCustomColAsList,{"Table1_2nd_Load"}),
    #"Extracted Values" = Table.TransformColumns(#"Removed Columns", {"Name Match", each Text.Combine(List.Transform(_, Text.From), "|"), type text})
in
    #"Extracted Values"
 
Upvote 0

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
OK lets see how we go with this.

1) Load your Table1 as a connection only query and in the right hand pane give it the name "Table1_2nd_Load" (without the quotes)
(that name is used in the code below)

2.1) Now either load the same table to Power Query again OR create a blank query.
2.2) Open the Advanced Editor of this query and replace everything you see there with the code below.
2.3) Close and Load To (select where to load it to, ideally give the query a meaningful name first)

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name1", type text}, {"Count1", Int64.Type}}),
    #"Merged Queries" = Table.FuzzyNestedJoin(#"Changed Type", {"Name1"}, Table1_2nd_Load, {"Name1"}, "Table1_2nd_Load", JoinKind.LeftOuter, [IgnoreCase=true, IgnoreSpace=true, Threshold=0.80]),
    AddCustomColAsList = Table.AddColumn(#"Merged Queries", "Name Match", each List.Sort([Table1_2nd_Load][Name1])),
    #"Removed Columns" = Table.RemoveColumns(AddCustomColAsList,{"Table1_2nd_Load"}),
    #"Extracted Values" = Table.TransformColumns(#"Removed Columns", {"Name Match", each Text.Combine(List.Transform(_, Text.From), "|"), type text})
in
    #"Extracted Values"
Yes that's brilliant! Thanks so much
 
Upvote 0

Forum statistics

Threads
1,223,996
Messages
6,175,853
Members
452,675
Latest member
duongtruc1610

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top