Table.CombineColumns

Table.CombineColumns is a Power Query M function that combines specified columns into a new column using a provided combiner function. The function returns a new table with the combined column.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

Table.CombineColumns(
   table as table,
   sourceColumns as list,
   combiner as function,
   column as text,
) as table
ArgumentAttributeDescription
tableThe table containing the columns.
sourceColumnsThe names of the columns to combine.
combinerCombiner Functions specify how columns should be combined. The argument can merge columns using different methods:
Combiner.CombineTextByDelimiter: using the specified delimiter.
Combiner.CombineTextByEachDelimiter: with each delimiter in a sequence.
Combiner.CombineTextByLengths: based on specified lengths.
Combiner.CombineTextByPositions: according to specified positions.
Combiner.CombineTextByRanges: using positions and lengths.
columnThe name of the combined column.

Description

Combines the specified columns into a new column using the specified combiner function.

Examples

Combine the last and first names into a new column, separated by a comma.

// Output: Table.FromRecords( {[FullName = "Smith,Bob"]} )
Table.CombineColumns( 
    Table.FromRecords( {[FirstName = "Bob", LastName = "Smith"]} ),
    {"LastName", "FirstName"},
    Combiner.CombineTextByDelimiter( ",", QuoteStyle.None ),
    "FullName"
 )

Other functions related to Table.CombineColumns are:

BI Gorilla Youtube Channel

Last update: August 25, 2023 | Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/table-combinecolumns
© 2023 BI Gorilla. All rights reserved. Content derived from Microsoft documentation is property of Microsoft Corp.