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
Argument | Attribute | Description |
---|---|---|
table | The table containing the columns. | |
sourceColumns | The names of the columns to combine. | |
combiner | Combiner 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. | |
column | The 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"
)
Related functions
Other functions related to Table.CombineColumns are:
- Table.CombineColumnsToRecord
- Table.PrefixColumns
- Table.SplitColumn
- Table.TransformColumnTypes
- Table.TransformColumns
- Table.TransformRows
