Power Query: Concatenate Values (Text and Numbers)

Last Updated: December 25, 2023
puneet-gogia-excel-champs

- Written by Puneet

In Power Query, there are multiple methods that you can use to concatenate values (numbers and text). And in this tutorial, we will learn to use these methods.

Below we have a list of first and last names in the columns:

concatenate-values-in-power-query

Concatenate Values from Two Columns into One (Combine Columns)

You can use these steps:

  1. First, load your data into the power query editor (Data > Get Data > From Other Sources > From Table/Range.
    concatenate-values-from-two-columns
  2. Afterward, select both columns in the editor and go to Transform > Merge Columns.
    transform-and-merge-columns
  3. When you click on the “Merge Columns”, you will get a dialog box that selects the separator and the name of the new column.
    select-separator-and-new-ceolumn-name
  4. Once you select the separator and column name, click OK. And hit enter to get the new column.
    get-new-column

Now, we have a new single column with values from both columns (first and last name). While you use this method, you need to take care of a few things:

  1. Select the columns in the sequence you want to combine the values.
  2. You can enter a custom separator in the dialog box.

 Concatenate Columns by Adding a New Column

Unlike the above method that we have used, you can also use a custom column and function to combine values.

  1. Go to the Add Column > Custom Column.
    concatenate-by-adding-new-column
  2. In the dialog box, you need to write a formula.
    write-a-formula-in-dialog-box
  3. Enter the column’s name and then enter the formula we used in the below snapshot.
    first-enter-column-name-and-then-formula
  4. Finally, click OK to enter the formula and create a new combined column.
    hit-enter-to-run-formula

In this formula, we have used an ampersand to combine values from both columns with a space in between. It is like a formula that we use in Excel.

=[First]&" "&[Last]

Combining Text and Number into One Column

In Power Query, if you try to combine the text with numbers, you will get an error in the final value.

combine-text-and-number-into-one-column

In this situation, you need NumberToText function to convert the number into text.

text-function-to-convert-number-to-text

And once you click OK after entering the formula. You will get a new custom column.

new-column-with-text-and-numbers-combined

Combining Values from a Single Column

If you have values in a column and want to get them in a single cell, you need to transpose them first.

combine-values-from-a-single-column

Select the column and click on “Transpose”.

select-column-then-click-transpose

Select the separator from the merge columns dialog box, enter the column name, and click OK.

select-seperator

You will get a new column with the values combined when you click OK.

new-column-with-combined-values

Get the Excel File

Download