Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Power Query Join Text: How to Merge Columns and Tables

· 7 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To join text in Power Query, you can either use the Merge Columns feature to combine multiple text fields into one column or use the Merge Queries feature to join two different tables based on a common text key. For a simple column combination, select the columns you want to join, go to the Transform tab, and select Merge Columns. For combining data from two separate sources, use the Home tab's Merge Queries option to perform a join (such as a Left Outer Join) based on matching text values.

What You'll Need

  • Microsoft Excel or Power BI Desktop with Power Query installed.
  • Two or more columns of text data within a single table (for column merging).
  • Two separate tables with a shared unique identifier or common text column (for table joining).
  • Data that has been imported into the Power Query Editor.

Step-by-Step

Depending on your goal, you will either be merging columns within one table or joining two different tables together. Both processes are essential for data normalization and cleaning.

Method 1: Merging Text Columns (Concatenation)

Use this method when you have data split across multiple columns—such as "First Name" and "Last Name"—and you want them in a single "Full Name" column.

  1. Open the Power Query Editor by going to the Data tab in Excel and selecting Get Data > Launch Power Query Editor (labels may vary slightly by version).
  2. In the Query Editor, hold the Ctrl key and click on the headers of the columns you wish to join. The order in which you select them is the order in which the text will appear in the final result.
  3. Navigate to the Transform tab on the top ribbon.
  4. Click on Merge Columns.
  5. A dialog box will appear. In the Separator dropdown, choose how you want to divide the text (e.g., Space, Comma, Semicolon, or Custom). If you choose Custom, you can type a specific character or string.
  6. In the New column name field, type a descriptive name for your joined text column, such as "Full Address" or "Combined ID".
  7. Click OK. Power Query will now create a single column containing the joined text from the selected sources.

Method 2: Joining Two Tables via Text Keys (Merge Queries)

Use this method when you have a primary table and a lookup table, and you want to bring text data from the second table into the first based on a matching text value.

  1. Ensure both tables are loaded into the Power Query Editor as separate queries.
  2. Select the primary table (the one you want to add data to) from the Queries pane on the left.
  3. Go to the Home tab and click Merge Queries. You can choose "Merge Queries" to modify the current table or "Merge Queries as New" to create a third table.
  4. In the Merge window, the first table is already selected. Click the dropdown menu in the center to select the second table you wish to join.
  5. Click on the column header in the first table that contains the join key (e.g., "Customer ID"). Then, click on the corresponding column header in the second table. Both columns must be the same data type (Text) for the join to work correctly.
  6. Under Join Kind, select the type of join you need. The most common is Left Outer, which keeps all rows from the first table and adds matching values from the second.
  7. Click OK. You will see a new column containing "Table" values.
  8. Click the Expand icon (two arrows pointing outward) in the header of the new column.
  9. Uncheck "Use original column name as prefix" and select only the specific text columns you want to bring over from the second table.
  10. Click OK to finalize the join.

Method 3: Joining Text via Custom Column (M Formula)

If you need more control—such as adding conditional text during the join—use a Custom Column.

  1. Go to the Add Column tab and select Custom Column.
  2. In the New column name box, give your column a name.
  3. In the Custom column formula box, use the ampersand (&) symbol to join text. For example: [FirstName] & " " & [LastName].
  4. If you need to join a text column with a number column, you must wrap the number in the Text.From() function. Example: .
  5. Click OK.

Common Mistakes

  • Ignoring Data Types: Trying to join a column formatted as "Whole Number" with a column formatted as "Text" in a Merge Query will result in no matches. Always ensure both key columns are set to the Text data type before merging.
  • Case Sensitivity: Power Query is case-sensitive. "Apple" and "apple" are treated as different values. If your text keys have inconsistent capitalization, the join will fail to find matches.
  • Leading and Trailing Spaces: Hidden spaces at the beginning or end of a text string (e.g., "ID123 " vs "ID123") are a frequent cause of failed joins. These are invisible to the eye but prevent a perfect match.
  • Wrong Join Kind: Using an "Inner Join" instead of a "Left Outer Join" can accidentally delete rows from your primary table if those rows don't have a corresponding match in the second table.
  • Selecting Columns in Wrong Order: When using the Merge Columns feature, the order of selection determines the order of the text. Selecting "City" then "State" results in "New York, NY", while the reverse results in "NY, New York".

Tips

  • Use Trim and Clean: Before performing a join or merge, right-click the text columns and select Transform > Trim (to remove leading/trailing spaces) and Transform > Clean (to remove non-printable characters).
  • Standardize Case: To avoid case-sensitivity issues, right-click the key columns and select Transform > lowercase or Transform > uppercase on both tables before joining.
  • Create a Helper Column: If you have complex join requirements, create a "Helper" column in both tables that concatenates multiple fields into one unique key, then join on that helper column.
  • Avoid Prefixing: When expanding a joined table, unchecking "Use original column name as prefix" keeps your headers clean and prevents long names like "CustomerTable.CustomerName".

Troubleshooting

If your joined text is returning nulls or the results are not what you expected, follow these steps in order:

  1. Check for Nulls: If you are using a Custom Column with the & operator, a single null value in one of the columns will make the entire result null. To fix this, use the Text.Combine function: Text.Combine({[Column1], [Column2]}, " "). This function ignores nulls.
  2. Verify Data Types: Look at the icon to the left of the column header. It should be "ABC" for text. If it says "123", click the icon and change it to Text.
  3. Test a Single Row: If a Merge Query isn't working, copy a value from the first table and manually search for it in the second table to ensure the value actually exists exactly as written.
  4. Refresh the Preview: Sometimes the Power Query preview doesn't update immediately. Click Refresh Preview in the Home tab to ensure you are seeing the most current data state.
  5. Check Join Kind: If rows are disappearing, change your Join Kind to "Left Outer" to ensure all rows from your primary table are preserved regardless of whether a match was found.

Frequently Asked Questions

Why is my merged column showing as null?

This usually happens when using the & operator in a custom column. If any of the columns being joined contain a null value, the entire result becomes null. Use the Text.Combine function to handle nulls gracefully.

Can I join more than two tables at once?

Power Query allows you to merge two tables at a time. To join three or more, merge the first two, expand the results, and then perform another Merge Query with the third table.

How do I join text with a date or number?

You cannot directly join different data types. You must first convert the date or number to text using the Transform > Data Type: Text menu or by using the Text.From() function in a custom column.

Is there a limit to how many columns I can merge?

There is no hard limit on the number of columns you can merge into one, but very large numbers of merged columns can impact performance and make the resulting data harder to analyze.

What is the difference between Merge and Append?

Merging joins tables horizontally (adding new columns based on a key), while Appending joins tables vertically (stacking rows from one table on top of another).