To concatenate text in Power Query, use the ampersand (&) operator or the Text.Combine function in a custom column or when editing an existing column. For example, to join FirstName and LastName with a space, create a custom column with the formula [FirstName] & " " & [LastName]. This works in both Excel and Power BI Desktop. You need a table loaded into Power Query and basic familiarity with the Power Query Editor.

What You'll Need

  • Excel (2016 or later) or Power BI Desktop with Power Query enabled.
  • A dataset loaded into Power Query (via Data > Get Data in Excel, or Get Data in Power BI).
  • Basic understanding of the Power Query Editor interface: ribbon, Queries pane, and formula bar.

Step-by-Step

  1. Open the Power Query Editor. In Excel, go to the Data tab and click "Get Data" > "Launch Power Query Editor" (or edit an existing query). In Power BI Desktop, click "Transform Data" on the Home ribbon.
  2. Select the table you want to work with from the Queries pane on the left.
  3. Add a custom column. Go to the "Add Column" tab on the ribbon and click "Custom Column". (In some versions, it's under the "General" group.)
  4. In the Custom Column dialog, give your new column a name (e.g., "FullName").
  5. Enter the concatenation formula. Use the ampersand (&) to join text values. For example, to combine FirstName and LastName with a space: [FirstName] & " " & [LastName]. Note: column names are case-sensitive and must be enclosed in square brackets. Text literals must be in double quotes.
  6. Click OK. The new column appears with the concatenated values.
  7. Alternatively, use Text.Combine for joining many columns or when you need a delimiter. For example: Text.Combine({[FirstName], [LastName]}, " "). This function takes a list of text values and a delimiter string.
  8. Handle null values. If any column is null, the result may be null. Use Text.From or the coalesce operator (??) to replace nulls with empty strings. For example: (Text.From([FirstName]) ?? "") & " " & (Text.From([LastName]) ?? "").
  9. Rename the column if needed. Double-click the column header or right-click and choose "Rename".
  10. Apply and close. Click "Close & Load" (Excel) or "Close & Apply" (Power BI) to load the transformed data.

Common Mistakes

  • Forgetting quotes around literal text. In Power Query, text strings must be in double quotes. For example, [FirstName] & " " & [LastName] is correct; omitting the quotes causes an error.
  • Using the wrong operator. The plus (+) sign does not concatenate text in Power Query; it's for numbers. Always use & or Text.Combine.
  • Not handling nulls. Concatenating a null value with text results in null. Use ?? "" or Text.From to avoid this.
  • Case sensitivity. Column names in Power Query are case-sensitive. Ensure you match the exact case.
  • Mixing data types. If a column contains numbers, convert them to text first using Text.From or change the column type.

Tips

  • Use Text.Combine when joining more than two columns or when you need a consistent delimiter.
  • Preview your formula in the Custom Column dialog before clicking OK to catch errors early.
  • If you need to concatenate all columns in a row, you can use Text.Combine(List.Transform(Record.FieldValues(_), Text.From), ", ") but be cautious with large tables.
  • Remember that Power Query is case-sensitive for column names, but text comparisons are case-insensitive by default.
  • Use the Advanced Editor to view and edit the M code directly for complex concatenations.

Troubleshooting

  • Error: "We cannot apply operator & to types Text and Number." This means one of the values is not text. Convert the column to text using the Transform tab or wrap it with Text.From.
  • Error: "The name 'FirstName' wasn't recognized." Check the column name spelling and case. Use the exact name as shown in the header.
  • Null results. If the concatenated result is null, at least one input is null. Use the coalesce operator (??) to replace nulls with empty strings.
  • Formula not updating. Ensure you're editing the correct step in the Applied Steps pane. Click the step to see its formula in the formula bar.
  • Custom column dialog not opening. Make sure you have a table selected and are on the Add Column tab. If the button is greyed out, you may need to load data first.

Frequently Asked Questions

Can I concatenate more than two columns?

Yes, simply chain them with &: [Col1] & [Col2] & [Col3]. Or use Text.Combine({[Col1], [Col2], [Col3]}, "").

How do I add a space or comma between concatenated values?

Include the delimiter as a text literal in quotes: [FirstName] & " " & [LastName] for a space, or for a comma and space.

Why does my concatenation return null?

If any input column contains null, the result is null. Use ?? "" to replace nulls with empty strings, or use Text.From with coalesce.

Can I concatenate numbers with text?

Yes, but you must convert numbers to text first using Text.From([NumberColumn]) or change the column data type to Text.

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

No practical limit, but very long formulas can become hard to read. Consider using Text.Combine with a list of columns for better readability.

Does concatenation work in Power Query for Excel and Power BI?

Yes, the methods are identical in both. The Power Query engine is the same.