我在使用Power Query(M语言)的Table.Join()函数时遇到了问题。为了演示这个问题,我修改了从Table.Join文档页面中提取的示例。
请注意最后的JoinKind.LeftOuter提示。
= Table.Join(
Table.FromRecords({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
"CustomerID",
Table.FromRecords({
[OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0],
[OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5.0],
[OrderID = 3, CustomerID = 2, Item = "Fishing net", Price = 25.0],
[OrderID = 4, CustomerID = 3, Item = "Fish tazer", Price = 200.0],
[OrderID = 5, CustomerID = 3, Item = "Bandaids", Price = 2.0],
[OrderID = 6, CustomerID = 1, Item = "Tackle box", Price = 20.0],
[OrderID = 7, CustomerID = 5, Item = "Bait", Price = 3.25]
}),
"CustomerID", JoinKind.LeftOuter
)
没有这个提示,函数可以正常运行。有了这个提示,由于重复的列名,函数会失败。
Expression.Error: A join operation cannot result in a table with duplicate column names ("CustomerID").
Details:
[Type]
从我的角度来看,这是一个bug,关键字不能重复。
我遇到了这个问题,因为我想要连接的两个表除了连接键之外共享相同的列名。是否有技巧可以类似于SQL给它们命名别名?