Table.CombineColumns
Merges several columns into one, with a function that makes one value of the row's values.
Group: Table. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
Table.CombineColumns(table as table, sourceColumns as list, combiner as function, column as text) as table
| Parameter | Type | Description |
|---|---|---|
table | table | The table with the columns. |
sourceColumns | list | The columns to merge, in the order their values are passed on. |
combiner | function | A function of a list of values, such as Combiner.CombineTextByDelimiter(" "). |
column | text | The merged column's name. |
Returns
table. The table with the source columns replaced by the merged one.
Remarks
- The merged column takes the place of the first source column.
Combiner.CombineTextByDelimiterjoins texts: change number columns to text first, as Transform data's Merge columns does.
Examples
First and last name
let
People = #table({"First", "Last", "Shop"}, {{"Kari", "Nordmann", "Oslo"}, {"Ola", "Hansen", "Bergen"}})
in
Table.CombineColumns(People, {"First", "Last"}, Combiner.CombineTextByDelimiter(" "), "Name")
| Name | Shop |
|---|---|
| Kari Nordmann | Oslo |
| Ola Hansen | Bergen |
A code from two parts
let
Products = #table({"Group", "Number", "Product"}, {{"FU", "001", "Chair"}, {"FU", "002", "Desk"}})
in
Table.CombineColumns(Products, {"Group", "Number"}, Combiner.CombineTextByDelimiter("-"), "Code")
| Code | Product |
|---|---|
| FU-001 | Chair |
| FU-002 | Desk |
Related functions
Table.SplitColumn, Table.CombineColumnsToRecord, Combiner.CombineTextByDelimiter, Table.AddColumn.