Inconsistent data — where "NORTH," "north," and "N" all mean the same thing — silently corrupts every analysis you run. This lesson teaches you how to find, replace, and standardize messy categories in Power Query using Replace Values, conditional columns, and scalable lookup table merges.

You pull sales data from your CRM system, combine it with data from a spreadsheet a regional manager has been maintaining for two years, and what you get is chaos. The "Region" column has "North," "NORTH," "north," "N," and "Northern Region" — all meaning exactly the same thing. The "Status" column has "Active," "active," "A," "ACT," and "Yes." Your "Product Category" column has "Electronics," "Electrnics," "electronic," and "ELECTRONICS." Before you can build a single chart or write a single formula, you need every one of those variations collapsed into a consistent, agreed-upon label.
This is one of the most common and most time-consuming problems in real-world data work, and Power Query is exceptionally well-suited to solving it. Rather than hunting through cells one at a time or writing nested IF statements in Excel, you can build a repeatable, documented cleaning process that runs automatically every time your data refreshes. By the end of this lesson, you'll know how to find inconsistencies, replace them systematically, handle case sensitivity, and even maintain a reusable lookup table so your standardization logic stays organized and scalable.
What you'll learn:
You should be comfortable opening the Power Query Editor and loading a table from a data source. If you're new to Power Query entirely, start with Getting Started with Power Query: Master Connect, Transform, Load for Real-World Data before continuing here.
You'll also benefit from a basic familiarity with Power Query's interface — specifically what the Applied Steps pane is and how steps chain together. If you've worked through data type changes or null handling, you're in good shape. For a refresher on those fundamentals, see Cleaning Messy Data with Power Query: Nulls, Errors, and Type Conversions.
Before jumping into the how, it's worth understanding the why — because it shapes the approach you'll take.
Missing data (nulls) is a known unknown. Your tools can count nulls, filter them, replace them with defaults. But inconsistent data is an unknown unknown. When "NORTH" and "north" and "N" are all present in your dataset, your model has no idea they're the same thing. A pivot table counts three separate regions. A chart draws three separate bars. A filter on "North" silently excludes the rows that say "NORTH." You get wrong answers that look like right answers — which is the most dangerous kind of error in data.
Standardization isn't just tidying up. It's enforcing the semantic truth of your data: that these different strings all mean the same thing, and your model should treat them that way.
Key insight
Inconsistency problems compound when you combine data from multiple sources. Even if each individual source is internally consistent, two sources that use different conventions will conflict when merged. Whenever you're combining data from multiple sources, plan for a standardization step as part of the process.
You can't fix what you can't see. Before replacing anything, you need a clear picture of what variants exist in a column.
In the Power Query Editor, go to the View tab on the ribbon and check "Column Distribution" and "Column Profile." These features show you a frequency breakdown of unique values in a column, which surfaces inconsistencies immediately. You'll see "North" appears 400 times, "NORTH" appears 12 times, "north" appears 3 times — a clear signal that cleaning is needed.
Tip
By default, column profiling only analyzes the first 1,000 rows. If your dataset is large, click the "Column profiling based on top 1000 rows" text at the bottom of the editor and switch it to "Column profiling based on entire data set." This gives you a complete picture before you start making changes.
Another fast technique: right-click the column header and select "Group By." Group by the column itself and count rows. Load the result as a new query temporarily. This gives you a table of every distinct value and how many times it appears — an audit table you can review before writing a single replacement rule.
The easiest tool in your toolkit is the Replace Values dialog. It works exactly like Find & Replace in Excel, but it operates at the query step level, meaning it's recorded, repeatable, and runs on every refresh.
Right-click any cell in the column you want to fix (or click the column header to select it), then choose Replace Values from the context menu. Alternatively, go to the Home tab and click Replace Values in the Transform group.
A dialog box appears with two fields: "Value to find" and "Replace with." Type the value you want to remove and the value you want to substitute it with, then click OK.
For example, to standardize "NORTH" to "North":
NORTHNorthThis generates a step in the Applied Steps pane and writes the following M code behind the scenes:
= Table.ReplaceValue(#"Previous Step", "NORTH", "North", Replacer.ReplaceText, {"Region"})
You can repeat this for each variant: one step for "NORTH" → "North," another for "north" → "North," another for "N" → "North," and so on.
Warning
Replace Values is case-sensitive by default. Typing "north" in the "Value to find" field will NOT match "NORTH." You need a separate replacement step for each distinct case variant — or you need a smarter approach, which we'll cover next.
If you have a small number of known variants (say, three or four), chaining simple Replace Values steps is perfectly fine. Each step is documented in the Applied Steps pane with a clear name. It's transparent, easy to audit, and easy to modify later. Don't overcomplicate it when simple works.
The case sensitivity limitation of Replace Values trips up almost everyone at first. There are two clean solutions.
If your column's values should all follow a specific casing convention, the cleanest approach is to normalize case first, then do your replacements.
Select the column, go to the Transform tab, and in the Text Column group click "Format." You'll see options: Lowercase, UPPERCASE, Capitalize Each Word, and Trim. Choose the one that matches your target convention.
For example, if your standard is Title Case ("North," "South," "East," "West"):
This two-step approach is elegant because it eliminates an entire category of variants in one move.
Tip
Always run Trim and Clean transformations on text columns before doing any value replacement. Trim removes leading and trailing spaces; Clean removes non-printable characters. A value that looks like "North" but has a trailing space will NOT match "North" in a replace rule. These invisible characters cause maddening false negatives. Find both options under Transform → Format.
If you don't want to change casing on the original column but still need to match case-insensitively, you can edit the M formula directly. Click the step in Applied Steps, go to the formula bar, and modify the Replacer function:
= Table.ReplaceValue(
#"Previous Step",
"north",
"North",
Replacer.ReplaceValue,
{"Region"}
)
The key is switching to Replacer.ReplaceValue (which replaces entire cell values) instead of Replacer.ReplaceText (which replaces substrings). But for true case-insensitive matching, you need to use a custom function:
= Table.ReplaceValue(
#"Previous Step",
each [Region],
each if Text.Lower([Region]) = "north" then "North" else [Region],
Replacer.ReplaceValue,
{"Region"}
)
This pattern — using each to pass the current row value and writing conditional logic inline — is powerful. You're essentially writing a row-by-row transformation that checks the lowercased value and decides what to output.
When you have many variants that need to map to several different standard values, chaining Replace Values steps becomes unwieldy. If you have 15 variants mapping to 4 categories, that's potentially 11 or more replacement steps cluttering your Applied Steps pane.
The cleaner solution is a Conditional Column — a new column that you build using if/else logic to output the correct standard value.
Go to Add Column → Conditional Column. In the dialog, you define a series of rules:
This generates a new column. You can then remove the original and rename the new one to match.
For working with more complex conditional logic, including nested conditions and computed values, the Conditional Column dialog has real limits. At that point you'll want to write a custom column formula in M directly:
= if Text.Lower(Text.Trim([Region])) = "n" or
Text.Lower(Text.Trim([Region])) = "north" or
Text.Lower(Text.Trim([Region])) = "northern region"
then "North"
else if Text.Lower(Text.Trim([Region])) = "s" or
Text.Lower(Text.Trim([Region])) = "south"
then "South"
else [Region]
This is expressive and handles trimming and case normalization in one expression. The tradeoff is that it lives inside a formula rather than a readable UI dialog — which is why documentation matters. Add a step name that clearly describes what this column does.
Note
When you add a conditional column, Power Query adds it to the right side of the table. After renaming and removing the original column, renaming and reordering your columns is good practice to keep your query output tidy and predictable for downstream tools.
Both Replace Values and conditional columns have a ceiling. When you have dozens of codes that need mapping — think product codes, country codes, department abbreviations, status flags — maintaining those rules inside the query itself becomes a maintenance nightmare. Every time a new variant appears, someone has to open the query editor and edit M code.
The professional solution is a lookup table: a separate table that maps raw values to their standard equivalents. You maintain the mapping in an Excel sheet or database table, and Power Query reads it and applies it automatically.
Create a small table (in Excel or any other source) with two columns: RawValue and StandardValue. For example:
| RawValue | StandardValue |
|---|---|
| N | North |
| NORTH | North |
| north | North |
| Northern Region | North |
| S | South |
| SOUTH | South |
| ACT | Active |
| active | Active |
| A | Active |
Load this table into Power Query as its own query. Call it something clear like RegionMapping or StatusLookup.
Now in your main data query, use a Merge operation to join your data to the lookup table:
The result: every raw variant that exists in your lookup table is replaced with its standard value. Variants not in the lookup table remain as-is (which is useful — you can spot unmapped values and add them to the lookup table over time).
Key insight
The lookup table approach separates your business rules from your transformation logic. The mapping lives in a file that a business analyst can maintain in Excel without ever touching Power Query. When new variants appear, they add a row to the spreadsheet — no code changes required. This is a core principle of maintainable ETL design.
Sometimes the value you need to fix isn't the whole cell — it's embedded inside a longer string. For example, a product code column might contain values like "PROD-ELEC-001" and "PROD-Electronic-002" where the middle segment is the category, but it's inconsistently capitalized or spelled.
This is where Replacer.ReplaceText (the default for Replace Values) becomes important. Unlike Replacer.ReplaceValue which only matches whole-cell values, ReplaceText finds and replaces substrings within a value.
For example:
= Table.ReplaceValue(
#"Previous Step",
"Electronic",
"ELEC",
Replacer.ReplaceText,
{"ProductCode"}
)
This would transform "PROD-Electronic-002" into "PROD-ELEC-002" without touching the rest of the string.
For cases involving patterns rather than exact strings — like "any code segment that starts with 'Elec'" — you'll want to split the column, standardize the segment, and recombine it. The Split, Merge, Pivot, and Unpivot techniques lesson covers how to split on delimiters, transform individual parts, and merge them back.
Here's a scenario to practice with. Create a table in Excel with the following data and load it into Power Query:
| OrderID | Region | Status | ProductCategory |
|---|---|---|---|
| 1001 | North | Active | Electronics |
| 1002 | NORTH | active | Electrnics |
| 1003 | N | ACT | ELECTRONICS |
| 1004 | South | Inactive | Clothing |
| 1005 | SOUTH | INACT | clothing |
| 1006 | northern region | A | Electonics |
| 1007 | East | Yes | Electronics |
Your tasks:
Stretch goal: Build your Region and Status mappings as a lookup table in a second Excel sheet and apply them via Merge instead of Replace Values steps.
"My Replace Values step isn't matching anything." The most common cause is invisible whitespace. The cell looks like it says "NORTH" but actually says " NORTH" (with a leading space) or "NORTH " (trailing space). Always Trim before replacing. The second most common cause is a data type mismatch — if the column is typed as a number or date, Replace Values on a text string won't work. Check your column type first.
"My conditional column is outputting the wrong value for some rows." Check your condition order. Power Query evaluates conditions top to bottom and stops at the first match. If you have a broad condition early (like "if Region contains 'N'") it may catch rows you didn't intend. Order your conditions from most specific to least specific.
"My lookup table merge created a lot of null values in the StandardValue column." This means those raw values don't exist in your lookup table. That's actually useful information — it shows you which variants you haven't mapped yet. Filter the merged table on null StandardValues to see the gap list, add those rows to your lookup table, and refresh.
"Replace Values changed values I didn't intend to change."
You're probably using Replacer.ReplaceText (substring matching) when you need Replacer.ReplaceValue (whole-cell matching). For example, replacing "N" with "North" using ReplaceText would turn "Northern Region" into "NorthhernRegion." Switch to ReplaceValue if your targets are always whole-cell values.
Warning
Be especially careful with short codes like single letters. Replacing "A" with "Active" using substring matching will corrupt any value that contains the letter A. Always use whole-value matching for short codes, and test your steps on a sample that includes edge cases.
You've now got a complete toolkit for standardizing inconsistent categorical data in Power Query:
Text.Lower() for robust matching without changing your original dataGood standardization work doesn't happen in isolation. It's part of a broader data cleaning pipeline that includes handling nulls and errors, fixing data types, and shaping columns to match downstream expectations. As you build more complex queries, you'll find that standardizing categories early — before joins, pivots, and aggregations — saves enormous debugging time later, because every downstream operation depends on consistent values to group and match correctly.
From here, consider exploring how filtering and sorting rows lets you validate your standardization work by isolating specific categories, or dive into grouping and aggregating data to see how clean, standardized categories enable accurate summaries and counts. If your inconsistencies are severe enough that even approximate string matching is needed — where "Electrnics" and "Electronics" need to be recognized as the same thing without explicit rules — look into fuzzy matching techniques in Power Query.
Power Query Essentials