Table.CombineColumns

Table

Combines multiple columns into a single column using a combiner function.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Table.CombineColumns(table as table, sourceColumns as list, combiner as function, column as text) as table

Parameters

NameTypeRequiredDescription
tabletableYesThe table containing the columns to combine.
sourceColumnslistYesA list of column names to combine.
combinerfunctionYesA combiner function such as Combiner.CombineTextByDelimiter or Combiner.CombineTextByLengths.
columntextYesThe name for the new combined column.

Return Value

tableA 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
    Combined
Result
EmployeeID
FullName
Department
1E001Alice SmithSales
2E002Bob JonesEngineering
3E003Charlie BrownMarketing

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
    Combined
Result
CustomerID
Name
Location
11AliceNew York, NY
22BobChicago, IL
33CharlieHouston, 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"
)
Result
Code
1AB123X

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks