OpenBI Docs Buy

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
ParameterTypeDescription
tabletableThe table with the columns.
sourceColumnslistThe columns to merge, in the order their values are passed on.
combinerfunctionA function of a list of values, such as Combiner.CombineTextByDelimiter(" ").
columntextThe 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.CombineTextByDelimiter joins 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")
NameShop
Kari NordmannOslo
Ola HansenBergen

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")
CodeProduct
FU-001Chair
FU-002Desk

Table.SplitColumn, Table.CombineColumnsToRecord, Combiner.CombineTextByDelimiter, Table.AddColumn.

Last updated · OpenBI Studio 0.3.79