Table.Join
Syntax
Table.Join(table1 as table, key1 as any, table2 as table, key2 as any, optional joinKind as nullable number, optional joinAlgorithm as nullable number, optional keyEqualityComparers as nullable list) as table
Acerca de
Combina las filas de table1 con las filas de table2 basándose en la igualdad de los valores de las columnas de clave que selecciona key1 (para table1) y key2 (para table2).
De forma predeterminada, se realiza una combinación interna, pero se puede incluir un elemento joinKind opcional para especificar el tipo de combinación. Entre las opciones se incluyen:
JoinKind.InnerJoinKind.LeftOuterJoinKind.RightOuterJoinKind.FullOuterJoinKind.LeftAntiJoinKind.RightAnti
Se puede incluir un conjunto opcional de keyEqualityComparers para especificar cómo se compararán las columnas de clave. Esta característica está pensada solo para uso interno.
Ejemplo 1
Combinar de forma interna las dos tablas en [CustomerID]
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"
)
| CustomerID | Nombre | Teléfono | OrderID | Elemento | Precio |
|---|---|---|---|---|---|
| 1 | Bob | 123-4567 | 1 | Fishing rod | 100 |
| 1 | Bob | 123-4567 | 2 | 1 lb. worms | 5 |
| 2 | Jim | 987-6543 | 3 | Fishing net | 25 |
| 3 | Paul | 543-7890 | 4 | Fish tazer | 200 |
| 3 | Paul | 543-7890 | 5 | Bandaids | 2 |
| 1 | Bob | 123-4567 | 6 | Tackle box | 20 |