Text.Replace in Power Query swaps every occurrence of a substring with another string, and it is case-sensitive by default. You can use it from the Power Query Editor's Replace Values command for a quick one-off fix, or write it by hand in the formula bar or Advanced Editor when you need exact control. The steps below cover both routes, plus what to do when a replacement does not stick.

What You'll Need

  • Power BI Desktop, Excel (Power Query is built into recent versions), or another host that runs Power Query.
  • A table already loaded into Power Query. If you are starting from scratch, use Data > Get Data in Excel or Home > Get Data in Power BI.
  • The exact text you want to find and the exact text you want it replaced with. Note that Text.Replace is case-sensitive.

Step-by-Step

  1. Open the Power Query Editor. In Excel, select any cell in your table and go to Data > From Table/Range. In Power BI Desktop, use Home > Transform data to open the editor on an existing query.
  2. Select the column you want to clean. Click its header so the column is highlighted. If you need to replace text across several columns, you will repeat the step per column or write a custom column instead.
  3. Use the quick route: right-click the column header and choose Replace Values. In the dialog, type the value to find and the replacement value, then click OK. Power Query writes a Text.Replace step for you and shows the result in the preview.
  4. Check the formula bar. The new step will read something like = Table.ReplaceValue(PreviousStep, "old", "new", Replacer.ReplaceText, {"ColumnName"}). This is the generated wrapper; it calls Text.Replace under the hood.
  5. For exact control, write the function directly. With the column selected, go to Add Column > Custom Column. Name the column, then enter a formula such as Text.Replace([ColumnName], "old", "new"). This keeps the original column and adds a cleaned copy, which is safer than overwriting.
  6. Press OK. The new column appears in the preview. Drag it to the position you want or remove the original column if you no longer need it.
  7. To replace more than one value, nest calls: Text.Replace(Text.Replace([ColumnName], "a", "b"), "c", "d"). The inner call runs first. For long lists of replacements, a small lookup table joined to the query is easier to maintain than deeply nested formulas.
  8. Apply and close. In Excel, use Home > Close & Load. In Power BI, use Home > Close & Apply. The cleaned column is now part of the query output.

Menu labels can differ slightly by version, device and region, but the Replace Values and Custom Column commands are present in current builds of both Excel and Power BI Desktop.

Common Mistakes

  • Expecting case-insensitive matching. Text.Replace is case-sensitive, so "apple" will not match "Apple". Use Text.Lower or Text.Upper on the input first if case does not matter, or use Text.Replace with a case-normalised copy.
  • Replacing a partial word by accident. Replacing "cat" also changes "category" to "category" only if the match is exact; it will change "concatenate" to "contenate". Test on a copy of the column before overwriting.
  • Using Replace Values when you need a new column. Replace Values edits the column in place. If you might need the original data later, use Custom Column instead.
  • Forgetting that nulls pass through. Text.Replace returns null for a null input. If you need a default value, wrap the call in if [Column] = null then null else Text.Replace(...).
  • Assuming the step is dynamic. The find and replace strings are fixed at the time you write the step. If they need to come from another table, use a merge or a parameter instead.

Tips

  • Preview the effect before committing: select the column, look at the bottom status bar for distinct and unique counts, then compare after the step.
  • Name your steps clearly. Right-click a step in the Applied Steps pane and choose Rename so the query reads like a recipe.
  • For repeated clean-ups, build a small replacement table with columns Find and Replace, merge it into your query, and expand the Replace column. This is easier to audit than nested Text.Replace calls.
  • Use Text.Replace with an empty string as the replacement to strip unwanted characters such as currency symbols or stray spaces.
  • Keep a duplicate query before large replacements. Duplicating the query (right-click > Duplicate) gives you a rollback point without touching the source data.

Troubleshooting

  • Nothing changed. Check case, leading and trailing spaces, and whether the value is stored as text. A number column will not match a text search until you change its type with Transform > Data Type > Text.
  • The step errors. Open the step and read the error message. A common cause is a missing column name after a rename, or a null where text was expected. Fix the column reference or add a null check.
  • The preview looks right but the loaded table is wrong. Check the order of Applied Steps. A later step may be changing the column type or filtering rows after your replacement.
  • Replace Values is greyed out. Make sure a single column is selected and the query is not in a state where editing is blocked, such as a direct query without the right permissions.
  • Performance is slow on large tables. Replace Values on a column is generally faster than a custom column with nested Text.Replace calls. Reduce the number of steps and avoid replacing text across the whole table when one column will do.

Frequently Asked Questions

Is Text.Replace case-sensitive?

Yes. "Apple" and "apple" are different strings. Normalise case first if you need a case-insensitive replace.

Can I replace multiple different values in one step?

Not with a single Text.Replace call. Nest calls or use a replacement lookup table merged into the query.

Does Text.Replace change the original data source?

No. It changes the query output only. The source file or database is untouched unless you write the result back.

What happens if the search string is not found?

The original text is returned unchanged. No error is raised.

Can I use Text.Replace on numbers or dates?

Only after converting the column to text. Convert with Transform > Data Type > Text, then replace, then convert back if needed.

Why does my replacement show in the preview but not after loading?

Check that the step is before the load step and that no later step re-applies the old value. Also confirm you loaded the correct query.