Table.AddJoinColumn
语法
Table.AddJoinColumn(table1 as table, key1 as any, table2 as function, key2 as any, newColumnName as text) as table
关于
基于 key1
(对于 table1
)和 key2
(对于 table2
)所选择的键列的值的相等性,联接 table1
的行与 table2
的行。 结果会输入到名为 newColumnName
的列中。 此函数的行为类似于 Table.Join(具有 LeftOuter 的 JoinKind),不同之处在于联接结果以嵌套而不是平展的方式呈现。
示例 1
从已联接 [saleID] 的表 ({[saleID = 1, price = 20], [saleID = 2, price = 10]}) 将名为“price/stock”的联接列添加到 ({[saleID = 1, item = "Shirt"], [saleID = 2, item = "Hat"]})。
使用情况
Table.AddJoinColumn(
Table.FromRecords({
[saleID = 1, item = "Shirt"],
[saleID = 2, item = "Hat"]
}),
"saleID",
() => Table.FromRecords({
[saleID = 1, price = 20, stock = 1234],
[saleID = 2, price = 10, stock = 5643]
}),
"saleID",
"price"
)
输出
Table.FromRecords({
[
saleID = 1,
item = "Shirt",
price = Table.FromRecords({[saleID = 1, price = 20, stock = 1234]})
],
[
saleID = 2,
item = "Hat",
price = Table.FromRecords({[saleID = 2, price = 10, stock = 5643]})
]
})