If you want to merge two or more columns into a single column in Power Query, like joining a first name and last name into one full name, the Table.CombineColumns function is what you reach for.
You hand it the columns to merge, tell it how to join the values, and name the new column.
In this article, I’ll show you how to use it across a handful of real examples.
Syntax of Table.CombineColumns Function
Table.CombineColumns(table as table, sourceColumns as list, combiner as function, column as text) as table
where
table(required, table). The table that holds the columns you want to merge.sourceColumns(required, list). The names of the columns to combine, as a list of text values, for example{"First","Last"}.combiner(required, function). The function that decides how the values are joined into one string. Most of the time this isCombiner.CombineTextByDelimiter(delimiter,QuoteStyle.None), which glues the values together with a separator you choose. This is the same idea as how you concatenate values into one. You can also pass a custom(values)=>...function for full control over the join.column(required, text). The name to give the new combined column.
Returns: a table where the source columns are replaced by one new column holding the combined values. The new column lands in the position of the first source column.
In plain terms, you point it at a few columns, tell it how to glue the values, and it gives you back the table with those columns merged into one.
Example 1: Combine first and last name into a full name
Say you have a Names query with a First and a Last column. You want one Full Name column instead.
Here is the starting data:
| First | Last |
|---|---|
| Ada | Lovelace |
| Alan | Turing |
| Grace | Hopper |
Merge the two columns with a space between them:
let
Source = Excel.CurrentWorkbook(){[Name="Names"]}[Content],
Combined = Table.CombineColumns(Source,{"First","Last"},Combiner.CombineTextByDelimiter(" ",QuoteStyle.None),"Full Name")
in
Combined
The First and Last columns are gone, replaced by a single Full Name column.
The result produces:
| Full Name |
|---|
| Ada Lovelace |
| Alan Turing |
| Grace Hopper |
Combiner.CombineTextByDelimiter(" ",QuoteStyle.None) joins each pair with a space.
Example 2: Build a full address with a comma separator
You have an Addr query split across Street, City, and State. You want one readable Address column.
Here is the starting data:
| Street | City | State |
|---|---|---|
| 12 Oak Lane | Austin | Texas |
| 88 Pine Road | Denver | Colorado |
| 7 Maple Court | Seattle | Washington |
Combine all three columns with a comma and space:
let
Source = Excel.CurrentWorkbook(){[Name="Addr"]}[Content],
Combined = Table.CombineColumns(Source,{"Street","City","State"},Combiner.CombineTextByDelimiter(", ",QuoteStyle.None),"Address")
in
Combined
You can pass as many columns as you like in the list, and they join in the order you list them.
The result produces:
| Address |
|---|
| 12 Oak Lane, Austin, Texas |
| 88 Pine Road, Denver, Colorado |
| 7 Maple Court, Seattle, Washington |
The delimiter is just text, so ", " puts a comma and a space between each piece.
Example 3: Make a code key with a dash delimiter
You have a Codes query with Region, Dept, and Slot. You want to stitch them into a single dash-separated key.
Here is the starting data:
| Region | Dept | Slot |
|---|---|---|
| West | Sales | Morning |
| East | Support | Evening |
| North | Finance | Night |
Join the three columns with a dash:
let
Source = Excel.CurrentWorkbook(){[Name="Codes"]}[Content],
Combined = Table.CombineColumns(Source,{"Region","Dept","Slot"},Combiner.CombineTextByDelimiter("-",QuoteStyle.None),"Code")
in
Combined
This is handy when you need a unique key built out of a few category columns.
The result produces:
| Code |
|---|
| West-Sales-Morning |
| East-Support-Evening |
| North-Finance-Night |
Any delimiter works, so you can swap the dash for a slash, a pipe, or whatever your downstream system expects.
Example 4: Keep the columns you do not combine
A lot of the time you have an ID column you want to leave alone. Here an Emp query has EmpID, First, and Last, and you only want to merge the two name columns.
Here is the starting data:
| EmpID | First | Last |
|---|---|---|
| E101 | Ada | Lovelace |
| E102 | Alan | Turing |
| E103 | Grace | Hopper |
Combine only First and Last:
let
Source = Excel.CurrentWorkbook(){[Name="Emp"]}[Content],
Combined = Table.CombineColumns(Source,{"First","Last"},Combiner.CombineTextByDelimiter(" ",QuoteStyle.None),"Full Name")
in
Combined
EmpID is left untouched, and the new Full Name column shows up where First used to be.
The result produces:
| EmpID | Full Name |
|---|---|
| E101 | Ada Lovelace |
| E102 | Alan Turing |
| E103 | Grace Hopper |
Only the columns you name get merged. Everything else stays exactly where it was.
Example 5: Skip null values with a custom combiner
The default combiner turns a null into an empty piece, which leaves stray delimiters. Here a Tags query has a Product, a Color, and a Size, and some color and size cells are blank.
Here is the starting data:
| Product | Color | Size |
|---|---|---|
| Shirt | Blue | Large |
| Cap | Small | |
| Bag | Green |
Pass a custom function that drops the nulls before joining:
let
Source = Excel.CurrentWorkbook(){[Name="Tags"]}[Content],
Combined = Table.CombineColumns(Source,{"Color","Size"},(values)=>Text.Combine(List.RemoveNulls(values),"/"),"Variant")
in
Combined
List.RemoveNulls strips out the blank values, so Text.Combine only joins what is actually there.
The result produces:
| Product | Variant |
|---|---|
| Shirt | Blue/Large |
| Cap | Small |
| Bag | Green |
The Cap and Bag rows have no leading or trailing slash, because the null was removed before the join instead of being kept as an empty segment.
Things to keep in mind with Table.CombineColumns
QuoteStyle.NoneversusQuoteStyle.Csv.QuoteStyle.Nonejoins values exactly as they are.QuoteStyle.Csvwraps any value containing the delimiter in double quotes, which is what you want when you are building a true CSV line.- Values must be text. A number column throws
Expression.Error: We cannot convert the value 5 to type Text.Wrap it withText.Fromfirst, for exampleText.From([Amount]). - It works within one table, column by column. It combines columns that sit side by side in the same table. To pull columns together from two separate queries, you merge queries first, then combine.
- It is the inverse of
Table.SplitColumn. If you ever need to undo the merge,Table.SplitColumnbreaks the combined column back apart on the delimiter. nullsource values leave empty segments. Anullshows up as an empty piece with the delimiter still around it, likeBlue/. Drop them with a custom combiner, or fill them first with the coalesce operator.
Common questions about Table.CombineColumns
What is the difference between Table.CombineColumns and the Merge Columns button?
They do the same thing. The Merge Columns button on the Transform tab is just the UI wrapper, and it writes a Table.CombineColumns step for you behind the scenes. Calling the function directly gives you the custom-combiner control that the button does not expose.
How do I combine columns without losing the originals?
Duplicate the columns first, then combine the copies. Right-click a column and choose Duplicate Column (or use Table.DuplicateColumn), then run Table.CombineColumns on the duplicates so the source columns stay in place.
How do I handle numbers or nulls when combining?
For numbers, convert each value to text with Text.From before combining, since the combiner only joins text. For nulls, pass a custom combiner that calls List.RemoveNulls so blanks do not leave stray delimiters (Example 5).
List of All Power Query Functions
Other Power Query articles you may also like:
Related Power Query Functions / Articles: