Table.CombineColumns
TableCombines multiple columns into a single column using a combiner function.
Syntax
Table.CombineColumns(table as table, sourceColumns as list, combiner as function, column as text) as tableParameters
| Name | Type | Required | Description |
|---|---|---|---|
table | table | Yes | The table containing the columns to combine. |
sourceColumns | list | Yes | A list of column names to combine. |
combiner | function | Yes | A combiner function such as Combiner.CombineTextByDelimiter or Combiner.CombineTextByLengths. |
column | text | Yes | The name for the new combined column. |
Return Value
table — A new table where the specified source columns have been merged into one column.
Remarks
Table.CombineColumns merges the values of multiple columns into a single new column using a combiner function, then removes the original source columns. The new column is inserted at the position of the first source column in the column order. Combiner functions from the Combiner.* namespace — Combiner.CombineTextByDelimiter, Combiner.CombineTextByLengths, and Combiner.CombineTextByRanges — control how the values are concatenated.
All source columns must be convertible to text for delimiter-based combiners. If numeric or other non-text columns are included, they will be implicitly converted. For more control over formatting, consider using Table.AddColumn with an explicit text expression and then removing the originals, which avoids implicit conversions and makes the format transparent.
Table.CombineColumns is the inverse of Table.SplitColumn: split a column into parts, work with them separately, then recombine. When recombining, ensure the delimiter used here matches what was used to split, or the round-trip will produce unexpected results.
Examples
Example 1: Combine first and last name columns from the Employees table
let
Employees = #table(
{"EmployeeID", "FirstName", "LastName", "Department"},
{{"E001","Alice","Smith","Sales"},{"E002","Bob","Jones","Engineering"},{"E003","Charlie","Brown","Marketing"}}
),
Combined = Table.CombineColumns(
Employees,
{"FirstName", "LastName"},
Combiner.CombineTextByDelimiter(" "),
"FullName"
)
in
CombinedEmployeeID | FullName | Department | |
|---|---|---|---|
| 1 | E001 | Alice Smith | Sales |
| 2 | E002 | Bob Jones | Engineering |
| 3 | E003 | Charlie Brown | Marketing |
Example 2: Build a full address string from city and state
let
Customers = #table(
{"CustomerID", "Name", "City", "State"},
{{1,"Alice","New York","NY"},{2,"Bob","Chicago","IL"},{3,"Charlie","Houston","TX"}}
),
Combined = Table.CombineColumns(
Customers,
{"City", "State"},
Combiner.CombineTextByDelimiter(", "),
"Location"
)
in
CombinedCustomerID | Name | Location | |
|---|---|---|---|
| 1 | 1 | Alice | New York, NY |
| 2 | 2 | Bob | Chicago, IL |
| 3 | 3 | Charlie | Houston, TX |
Example 3: Combine fixed-width segments using CombineTextByLengths
Table.CombineColumns(
#table({"Part1", "Part2", "Part3"}, {{"AB","123","X"}}),
{"Part1", "Part2", "Part3"},
Combiner.CombineTextByLengths({2, 3, 1}),
"Code"
)Code | |
|---|---|
| 1 | AB123X |