Wicked Smart Data
LearnInsightsAboutContact
Sign InLet's Build
LearnInsightsAboutContact
Sign InLet's Build
Wicked Smart Data

Intelligence, automation, and expert execution — plus an elite library of free knowledge. We turn complexity into competitive advantage.

Start a conversation

Platform

  • Learning Paths
  • Insights
  • RSS Feed

Company

  • About
  • Contact
  • Work With Us

Legal

  • Privacy Policy
  • Terms of Service

© 2026 Wicked Smart Data. All rights reserved.

Intelligence · Automation · Advantage

All Insights
Power Query

Replacing Values and Fixing Inconsistent Entries in Power Query: Standardizing Categories, Codes, and Labels

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.

🌱 Foundation16 min readNov 28, 2026Updated Nov 28, 2026
Replacing Values and Fixing Inconsistent Entries in Power Query: Standardizing Categories, Codes, and Labels
On this page
  • Introduction
  • Prerequisites
  • Why Inconsistent Data Is Worse Than Missing Data
  • Step 1: Finding the Inconsistencies
  • Using the Column Distribution and Profile
  • Right-Click to Group: A Quick Audit Trick
  • Step 2: The Replace Values Dialog — Simple Substitutions
  • How to Use It
  • When Simple Replace Is Enough
  • Step 3: Handling Case Sensitivity the Right Way
  • Option A: Normalize Case First, Then Replace
  • Option B: Write a Case-Insensitive Replace in M
  • Step 4: Mapping Multiple Variants with Conditional Columns
  • Step 5: The Lookup Table Approach — Scalable Standardization
  • Setting Up the Lookup Table
  • Applying the Lookup with a Merge
  • Step 6: Fixing Partial Matches and Embedded Codes
  • Hands-On Exercise
  • Common Mistakes & Troubleshooting
  • Summary & Next Steps

Replacing Values and Fixing Inconsistent Entries in Power Query: Standardizing Categories, Codes, and Labels

Introduction

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:

  • How to use Power Query's built-in Replace Values feature for simple substitutions
  • How to handle case-insensitive matching and trim hidden whitespace that breaks comparisons
  • How to use conditional logic to map multiple variants to a single standard value
  • How to build and apply a lookup table for large-scale, maintainable standardization
  • How to write M code for Replace Values operations when the UI isn't flexible enough

Prerequisites

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.


Why Inconsistent Data Is Worse Than Missing Data

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.


Step 1: Finding the Inconsistencies

You can't fix what you can't see. Before replacing anything, you need a clear picture of what variants exist in a column.

Using the Column Distribution and Profile

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.

Right-Click to Group: A Quick Audit Trick

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.


Step 2: The Replace Values Dialog — Simple Substitutions

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.

How to Use It

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":

  • Value to find: NORTH
  • Replace with: North

This 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.

When Simple Replace Is Enough

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.


Step 3: Handling Case Sensitivity the Right Way

The case sensitivity limitation of Replace Values trips up almost everyone at first. There are two clean solutions.

Option A: Normalize Case First, Then Replace

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"):

  1. Apply "Capitalize Each Word" to normalize all variants to Title Case
  2. Now "NORTH," "north," and "North" all become "North"
  3. Run Replace Values only for the genuinely different abbreviations like "N" → "North"

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.

Option B: Write a Case-Insensitive Replace in M

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.


Step 4: Mapping Multiple Variants with Conditional Columns

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:

  • If "Region" equals "N" then output "North"
  • If "Region" equals "NORTH" then output "North"
  • If "Region" equals "north" then output "North"
  • If "Region" equals "S" then output "South"
  • ... and so on
  • Else output [Region] (keep the value as-is for anything already correct)

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.


Step 5: The Lookup Table Approach — Scalable Standardization

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.

Setting Up the Lookup Table

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.

Applying the Lookup with a Merge

Now in your main data query, use a Merge operation to join your data to the lookup table:

  1. Go to Home → Merge Queries
  2. Select your main table's raw column (e.g., "Region") as the left key
  3. Select your lookup table as the right table, and "RawValue" as the right key
  4. Choose "Left Outer" join (this keeps all rows from your main table, even if no match is found)
  5. After merging, expand the lookup table column and select only "StandardValue"
  6. Rename the new column and remove the original raw column

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.


Step 6: Fixing Partial Matches and Embedded Codes

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.


Hands-On Exercise

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:

  1. Trim and clean all three non-ID columns to remove any hidden whitespace.
  2. Standardize "Region" so that all variants of North become "North," all variants of South become "South," and "East" stays as-is. Use whatever method you prefer — Replace Values, conditional column, or a lookup table you build in a second sheet.
  3. Standardize "Status" so that "Active," "active," "ACT," "A," and "Yes" all become "Active," and "Inactive" and "INACT" become "Inactive."
  4. Standardize "ProductCategory" so that all misspellings and case variants of Electronics become "Electronics" and clothing variants become "Clothing."
  5. After all replacements, check the Column Distribution view to confirm each column has only the expected distinct values.

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.


Common Mistakes & Troubleshooting

"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.


Summary & Next Steps

You've now got a complete toolkit for standardizing inconsistent categorical data in Power Query:

  • Replace Values for small numbers of known, exact substitutions
  • Trim, Clean, and case normalization to eliminate invisible whitespace and case sensitivity as confounders before replacing
  • Case-insensitive M formulas using Text.Lower() for robust matching without changing your original data
  • Conditional Columns for multi-branch mapping logic when you have several variants mapping to several standard values
  • Lookup table merges for large-scale, externally maintainable mapping rules that separate your business logic from your transformation code

Good 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.

Work With Us

From insight to implementation

Reading is the start. When you're ready to build the data, automation, or AI systems behind it, our team turns strategy into shipped results.

Let's Build

Power Query Essentials

Previous

Implementing Custom Audit Logging and Lineage Tracking in Power Query M: Capturing Row Counts, Source Metadata, and Transformation Timestamps Across Multi-Step ETL Pipelines

Related Insights

Power QueryExpert

Implementing Custom Function Memoization and Result Caching in Power Query M: Building Stateless Computation Patterns That Minimize Redundant Evaluations Across Complex Query Graphs

25 min
Power QueryExpert

Implementing Custom Audit Logging and Lineage Tracking in Power Query M: Capturing Row Counts, Source Metadata, and Transformation Timestamps Across Multi-Step ETL Pipelines

25 min
Power QueryPractitioner

Implementing Custom Query Parameterization via Function Currying in Power Query M: Building Composable, Argument-Driven Transformation Pipelines for Multi-Context Reuse

21 min

On this page

  • Introduction
  • Prerequisites
  • Why Inconsistent Data Is Worse Than Missing Data
  • Step 1: Finding the Inconsistencies
  • Using the Column Distribution and Profile
  • Right-Click to Group: A Quick Audit Trick
  • Step 2: The Replace Values Dialog — Simple Substitutions
  • How to Use It
  • When Simple Replace Is Enough
  • Step 3: Handling Case Sensitivity the Right Way
  • Option A: Normalize Case First, Then Replace
  • Option B: Write a Case-Insensitive Replace in M
  • Step 4: Mapping Multiple Variants with Conditional Columns
  • Step 5: The Lookup Table Approach — Scalable Standardization
  • Setting Up the Lookup Table
  • Applying the Lookup with a Merge
  • Step 6: Fixing Partial Matches and Embedded Codes
  • Hands-On Exercise
  • Common Mistakes & Troubleshooting
  • Summary & Next Steps