Table.ReplaceValue()
Learn how Table.ReplaceValue finds and replaces values across specific columns, why it requires an explicit column list, and how ReplaceValue differs from ReplaceText.
Table.ReplaceValue()
Table.ReplaceValue() finds and replaces a value across one or more columns of a table — the function behind Transform > Replace Values in the Editor.
Table.ReplaceValue(
table as table,
oldValue as any,
newValue as any,
replacer as function,
columnsToSearch as list
) as tableBasic Example
#"Replaced Value" = Table.ReplaceValue(
Source, "N/A", null, Replacer.ReplaceValue, {"Amount"}
)Amount Amount
1200 1200
N/A -> null <- replaced
850 850The Column List Is Not Optional in Practice
The last argument, columnsToSearch, is a required list of column names — the replace only runs against the columns named there, not the whole table. This is the single most common source of confusion with this function.
#"Replaced Value" = Table.ReplaceValue(
Source, "N/A", null, Replacer.ReplaceValue, {"Amount"}
)If the same placeholder also appears in a Quantity column that wasn't listed, it's left completely untouched — no error, no warning, just a silent miss in a column nobody remembered to add to the list.
Fix: explicitly list every column that could contain the value.
#"Replaced Value" = Table.ReplaceValue(
Source, "N/A", null, Replacer.ReplaceValue, {"Amount", "Quantity", "Discount"}
)Replacer.ReplaceValue vs. Replacer.ReplaceText
The replacer argument controls match behavior, and the two most common options behave differently:
| Replacer.ReplaceValue | Replacer.ReplaceText | |
|---|---|---|
| Match type | Exact, whole-value match | Substring match, text columns only |
"N/A" matches | Only a cell that is exactly "N/A" | Any cell containing "N/A" anywhere in it |
| Works on | Any data type | Text only |
-- Exact match: only replaces a cell that IS "N/A"
Table.ReplaceValue(Source, "N/A", "", Replacer.ReplaceValue, {"Notes"})
-- Substring match: replaces "N/A" wherever it appears within the text
Table.ReplaceValue(Source, "N/A", "", Replacer.ReplaceText, {"Notes"})Using Replacer.ReplaceValue on a Notes column expecting it to strip "N/A" out of a longer sentence like "Status: N/A for now" won't do anything — the cell isn't exactly "N/A", just contains it. That case needs Replacer.ReplaceText.
Try it live — check both columns and switch the replacer to catch everything
Source table
| Notes | Status |
|---|---|
Result
| Notes | Status |
|---|---|
| (empty) | N/A |
| Status: N/A for now | Active |
| Complete | N/A |
— 3 rows still have an untouched "N/A", highlighted above. No error, no warning — either the column holding it isn't in columnsToSearch, or it's sitting inside a longer string that Replacer.ReplaceValue's exact-match check doesn't catch. Check both columns and switch to Replacer.ReplaceText to catch every case.
Common Mistakes
Assuming It Searches the Whole Table
As covered above — a column left off the list is silently skipped, not searched-and-found-nothing. Always double-check the column list against every place the value could actually appear.
Using ReplaceValue When ReplaceText Was Needed
Expecting an exact-match replacer to catch a substring inside a longer text value — it won't, and it fails silently rather than erroring, since the operation itself is still valid, it just never matches.
Replacing Text and Non-Text Values With the Same Call
Replacer.ReplaceText only works on columns typed as Text — pointing it at a numeric or date column throws a type error, since there's no "substring" concept for those types. Use Replacer.ReplaceValue for anything that isn't text.
Not Checking for Multiple Placeholder Variants
A source with "N/A" in some rows often has "n/a", "-", or a blank string elsewhere too, from different people entering data inconsistently. One Table.ReplaceValue() call only catches the exact variant it was given — checking for the full set of placeholders actually present (via a quick Table.Distinct() on the column) avoids fixing only part of the problem.
Next Steps
- M Language
- M Function Reference
- Transformations
- Text.Contains() & Text.Replace() — the substring-level version of the same problem
Cleaning up placeholder values as part of a broader type-conversion error? See We Couldn't Convert to Number (or Date) for the fuller pattern, including locale mismatches and hidden whitespace.
Table.Pivot() & Table.Unpivot()
Learn how Table.Pivot and Table.Unpivot reshape data between wide and long formats, why "Unpivot Other Columns" matters for future-proofing a query, and the aggregation function Pivot requires.
Text.Trim(), Text.Upper() & Text.Lower()
Learn how Text.Trim, Text.Upper, and Text.Lower clean up text values, why Text.Trim doesn't always catch what looks like whitespace, and when case-insensitive comparison is the better fix than converting case at all.