Table.FuzzyNestedJoin
TableJoins two tables using fuzzy string matching and produces a nested table column of matches.
Syntax
Table.FuzzyNestedJoin(table1 as table, key1 as any, table2 as table, key2 as any, newColumnName as text, optional joinKind as nullable number, optional joinOptions as nullable record) as tableParameters
| Name | Type | Required | Description |
|---|---|---|---|
table1 | table | Yes | The left table. |
key1 | any | Yes | The key column name or list of column names from table1. |
table2 | table | Yes | The right table. |
key2 | any | Yes | The key column name or list of column names from table2. |
newColumnName | text | Yes | The name for the new nested table column added to table1. |
joinKind | number | No | Optional. The join type (JoinKind.Inner, JoinKind.LeftOuter, etc.). Defaults to JoinKind.LeftOuter. |
joinOptions | record | No | Optional record with fuzzy matching options: Threshold, IgnoreCase, IgnoreSpace, NumberOfMatches, TransformationTable. |
Return Value
table — The left table with a new column containing nested tables of fuzzy-matched rows from the right table.
Remarks
Table.FuzzyNestedJoin is the fuzzy-matching counterpart of Table.NestedJoin. Instead of requiring exact key equality, it matches keys using approximate string similarity and stores all matching right-table rows in a nested table column. This is useful when you need to inspect all fuzzy matches per left-table row before deciding which to keep, or when you want to count matches rather than flatten them immediately.
The joinOptions record accepts the same fields as Table.FuzzyJoin: Threshold, IgnoreCase, IgnoreSpace, NumberOfMatches, and TransformationTable. The default joinKind is JoinKind.LeftOuter. Use Table.ExpandTableColumn to flatten the nested matches into additional columns.
Prefer Table.FuzzyNestedJoin over Table.FuzzyJoin when you want to handle one-to-many matches explicitly — for example, counting the number of fuzzy matches per row or selecting the best match based on a custom criterion. For a direct flat join without the nested intermediate step, use Table.FuzzyJoin.
Examples
Example 1: Fuzzy nested join — Sales with misspelled names against Customers
let
Orders = #table(
{"OrderID", "CustomerName", "Amount"},
{{1,"Alise",250},{2,"Bobb",180},{3,"Charlei",300},{4,"Diana",150}}
),
Customers = #table(
{"Name", "City"},
{{"Alice","New York"},{"Bob","Chicago"},{"Charlie","Houston"},{"Diana","Seattle"}}
),
Joined = Table.FuzzyNestedJoin(
Orders, "CustomerName",
Customers, "Name",
"CustomerMatches",
JoinKind.LeftOuter,
[Threshold = 0.75]
)
in
JoinedOrderID | CustomerName | Amount | CustomerMatches | |
|---|---|---|---|---|
| 1 | 1 | Alise | 250 | [Table] |
| 2 | 2 | Bobb | 180 | [Table] |
| 3 | 3 | Charlei | 300 | [Table] |
| 4 | 4 | Diana | 150 | [Table] |
Example 2: Expand the nested column to bring in City data
let
Orders = #table({"OrderID","CustomerName","Amount"},{{1,"Alise",250},{2,"Bobb",180}}),
Customers = #table({"Name","City","State"},{{"Alice","New York","NY"},{"Bob","Chicago","IL"}}),
Joined = Table.FuzzyNestedJoin(Orders,"CustomerName",Customers,"Name","CustomerMatches",JoinKind.LeftOuter,[Threshold=0.75]),
Expanded = Table.ExpandTableColumn(Joined, "CustomerMatches", {"Name","City","State"}, {"CanonicalName","City","State"})
in
ExpandedOrderID | CustomerName | Amount | CanonicalName | City | State | |
|---|---|---|---|---|---|---|
| 1 | 1 | Alise | 250 | Alice | New York | NY |
| 2 | 2 | Bobb | 180 | Bob | Chicago | IL |
Example 3: Count fuzzy matches per order row
let
Orders = #table({"OrderID","Product"},{{1,"Widge A"},{2,"Gadgit B"},{3,"Xyz"}}),
Products = #table({"CanonicalName"},{{"Widget A"},{"Widget C"},{"Gadget B"},{"Gadget D"}}),
Joined = Table.FuzzyNestedJoin(Orders,"Product",Products,"CanonicalName","Matches",JoinKind.LeftOuter,[Threshold=0.6]),
WithCount = Table.AddColumn(Joined, "MatchCount", each Table.RowCount([Matches]), type number),
Result = Table.RemoveColumns(WithCount, {"Matches"})
in
ResultOrderID | Product | MatchCount | |
|---|---|---|---|
| 1 | 1 | Widge A | 2 |
| 2 | 2 | Gadgit B | 2 |
| 3 | 3 | Xyz | 0 |