Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

In Power Query, you can merge two or more columns in your query. You can merge columns to replace them with one merged column, or create a new merged column alongside the columns that are merged. You can only merge columns of a Text data type. The following data is used in the examples.

Tip    It's a good idea to create a new column and keep the original columns so you can better prevent refresh errors that might happen down the road.

Sample data used to explain the Merge command

When you merge columns, the selected columns are turned into one column called Merged. The original two columns are no longer available. 

In this example, we merge OrderID and CustomerID.

  1. To open a query, locate one previously loaded from the Power Query Editor, select a cell in the data, and then select Query > Edit. For more information see Create, load, or edit a query in Excel.

  2. Ensure that the columns that you want to merge are the Text data type. If necessary, select the column, and then select Transform Data Type > Text.

  3. Select two or more columns that you need to merge. To select more than one column contiguously or discontiguously, press Shift+Click or CTRL+Click on each subsequent column.

    The order of selection sets the order of the merged values.

  4. Select  Transform Merge Columns.

  5. In the Merge Columns dialog box, specify a separator to insert between each merged column. You can select from predefined separator values, or specify a custom separator value.

    Select a seperator

  6. Select OK.

Result

Merged column

You can rename the merged column so that it is more meaningful to you. For more information, see Rename a column.

You can insert a custom column into the query table and use a custom column to effectively merge two or more columns. In this case, the merged columns are still available along with the new merged column in the query table.

In this example, we are merging OrderID and CustomerID separated by a space character.

  1. To open a query, locate one previously loaded from the Power Query Editor, select a cell in the data, and then select Query > Edit. For more information see Create, load, or edit a query in Excel.

  2. Ensure that the columns that you want to merge are of Text data type. Select Transform Change Type > Text.

  3. Select  Add Column  Custom Column. The Custom Column dialog box appears.

  4. In the Available Columns list, select the first column, and then select Insert. You can also double-click the first column. The column is added to the Custom Column Formula box immediately after the equal sign (=).

    Tip    In the Custom Column Formula box, press Ctrl + Space to display columns and other formula elements.

  5. In the Custom Column Formula box, enter an ampersand (&) after the first column that you inserted.

    The ampersand (&) operator is used to combine values in Power Query in the same way as in Excel.

  6. You can specify an additional separator, for example a space character, by entering " " after the ampersand (&).

  7. In the Custom Column Formula box, enter another ampersand (&) after the space character.

  8. In the Available Columns list, select the second column, and then select Insert. You can also double-click the second column. 

    Specify custom column formula to merge column values

  9. Select OK. 

Result

Custom merged column

You can rename the custom column so that it is more meaningful to you. For more information, see Rename a column.

See Also

Power Query for Excel Help

Add a custom column

Add or change data types

Combiner functions (docs.com)

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×