Table.FuzzyNestedJoin
在資料表之間對提供的資料行執行模糊聯結,並在新的資料行中產生聯結結果。
Syntax
Table.FuzzyNestedJoin(
table1 as table,
key1 as any,
table2 as table,
key2 as any,
newColumnName as text,
optional joinKind as JoinKind.Type,
optional joinOptions as record
) as table
Remarks
依據 key1 (代表 table1) 與 key2 (代表 table2) 選取之索引鍵資料行的值所進行的模糊比對,聯結 table1 的資料列與 table2 的資料列。結果會以名為 newColumnName 的新資料行傳回。
模糊比對只會比較文字的相似度,不會要求文字完全一致。
joinKind (選擇性) 可指定要執行的聯結種類。若未指定 joinKind,則預設會執行左方外部聯結。選項包含:
JoinKind.InnerJoinKind.LeftOuterJoinKind.RightOuterJoinKind.FullOuterJoinKind.LeftAntiJoinKind.RightAntiJoinKind.LeftSemiJoinKind.RightSemi
可以選擇納入一組 joinOptions,以指定比較索引鍵資料行的方式。選項包含:
ConcurrentRequests: 介於 1 到 8 之間的數字,指定要用於模糊比對的平行執行緒數目。預設值為 1。Culture: 允許依據文化特性專屬的規則比對記錄。其可以是任何有效的文化特性名稱。例如,"ja-jp" 的文化特性選項會根據日文文化特性為記錄分組。預設值為 "",即不因文化特性而異 (英文) 進行比對。IgnoreCase: 邏輯 (true/false) 值,允許不區分大小寫的索引鍵比對。例如,若為 true,"Grapes" 會與 "grapes" 相符。預設值為 true。IgnoreSpace: 邏輯 (true/false) 值,允許合併文字部分以尋找相符項目。例如,若為 true,"Gra pes" 會與 "Grapes" 相符。預設值為 true。NumberOfMatches: 指定每個輸入資料列可傳回之相符資料列數目上限的整數。例如,值為 1 時,每個輸入資料列最多傳回一個相符的資料列。若未提供此選項,則會傳回所有相符的資料列。SimilarityColumnName: 顯示輸入值與該輸入之代表值之相似性的資料行名稱。預設值為 Null,表示將不會新增資料行顯示相似性。Threshold: 介於 0.00 到 1.00 之間的數字,指出比對兩個值所依據的相似度分數。 例如,只有在此選項設定為小於 0.90 時,「Grapes」才會與「Graes」(缺少「p」) 相符。 閾值 1.00 表示指定條件為完全相符。 (請注意,模糊的「完全相符」可能會忽略大小寫、字順序和標點符號等差異。) 預設值為 0.80。TransformationTable: 允許依據自訂值比對來比對記錄的資料表。其應包含 "From" 和 "To" 資料行。例如,如果提供轉換資料表,而 "From" 資料行包含 "Grapes",且 "To" 資料行包含 "Raisins",則 "Grapes" 會與 "Raisins" 相符。請注意,轉換會套用到轉換資料表中該文字出現的所有地方。使用上述轉換資料表時,"Grapes are sweet" 也會與 "Raisins are sweet" 相符。
Examples
Example #1
根據 [FirstName] 留下兩個資料表的內部模糊聯結
Table.FuzzyNestedJoin(
Table.FromRecords(
{
[CustomerID = 1, FirstName1 = "Bob", Phone = "555-1234"],
[CustomerID = 2, FirstName1 = "Robert", Phone = "555-4567"]
},
type table [CustomerID = nullable number, FirstName1 = nullable text, Phone = nullable text]
),
{"FirstName1"},
Table.FromRecords(
{
[CustomerStateID = 1, FirstName2 = "Bob", State = "TX"],
[CustomerStateID = 2, FirstName2 = "bOB", State = "CA"]
},
type table [CustomerStateID = nullable number, FirstName2 = nullable text, State = nullable text]
),
{"FirstName2"},
"NestedTable",
JoinKind.LeftOuter,
[IgnoreCase = true, IgnoreSpace = false]
)
Result:
Table.FromRecords({
[
CustomerID = 1,
FirstName1 = "Bob",
Phone = "555-1234",
NestedTable = Table.FromRecords({
[
CustomerStateID = 1,
FirstName2 = "Bob",
State = "TX"
],
[
CustomerStateID = 2,
FirstName2 = "bOB",
State = "CA"
]
})
],
[
CustomerID = 2,
FirstName1 = "Robert",
Phone = "555-4567",
NestedTable = Table.FromRecords({})
]
})
Category
Table.Transformation