Power Query Problems

Identify and Replace Hidden Characters in Excel Power Query Text

Muhammad TalhaMuhammad Talha Nov 18, 2026 869 views

Question details

Identify nonstandard space characters in API-imported text and replace them so matching values can be merged.

Identify and Replace Hidden Characters in Excel Power Query Text
Product
Microsoft Excel Power Query
Device & OS
not provided
Scenario
An API supplies text values that need to match corresponding values in a Power Query merge.
Observed behavior
Text values that appear to match may not merge because they contain different space characters.
Before you start

Open the affected query in Power Query Editor and identify the text columns used as merge keys. Have an example of a value that fails to match so you can inspect its character codes.

Solution 1Recommended

Inspect Character Codes and Normalize the Merge Columns

Use a Power Query custom column to identify hidden characters, then replace the identified character on both sides of the merge.

1
Inspect the characters

In Power Query Editor, select Add Column > Custom Column. Name the column Character Codes and enter: if [Contract] = null then null else Text.Combine(List.Transform(Text.ToList([Contract]), each Text.From(Character.ToNumber(_))), ", "). Replace Contract with your column name.

2
Find the unusual code

Compare Character Codes for a nonmatching value with the corresponding value in the other query. For example, 160 represents a nonbreaking space, while 32 represents a standard space.

3
Create a cleaned merge key

Select Add Column > Custom Column and enter: if [Contract] = null then null else Text.Trim(Text.Replace([Contract], Character.FromNumber(160), " ")). Replace 160 with the code you found and Contract with your column name.

4
Clean and merge both queries

Repeat the cleaning step in the other query as needed. Select Home > Merge Queries, choose the cleaned key column in each table, and check that the expected rows match.

Inspect Character Codes and Normalize the Merge Columns
Check the character before replacing it: Code 160 is an example, not necessarily the character in your data. Text.Trim removes leading and trailing whitespace; Text.Clean removes control characters but does not replace every nonstandard space.
Free Microsoft Office alternative

Review Spreadsheet Text with WPS Office

WPS Office is a free, lightweight alternative for opening and editing spreadsheets in a familiar interface. Its Microsoft Office format compatibility makes it easy to move existing files, though it does not fix Microsoft Power Query merges.

Review and edit imported text in WPS SpreadsheetsOpen and save Microsoft Excel formats such as XLSXUse a familiar spreadsheet interface for an easier transitionWork with a free, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Why do values that look identical fail to merge?

They may contain different characters, such as a standard space and a nonbreaking space. In Power Query, use Text.ToList and Character.ToNumber to compare the character codes.

How do I replace a nonbreaking space in Power Query?

In Add Column > Custom Column, use Text.Replace([Contract], Character.FromNumber(160), " "), changing Contract to your column name. Handle null values separately if the column contains them.

Should I clean both columns before merging?

Yes. Apply consistent replacement and trimming rules to the merge key in each query, then select those cleaned columns in Home > Merge Queries.

Will Text.Clean remove nonbreaking spaces?

Text.Clean removes control characters, but it is not a substitute for explicitly replacing a nonbreaking space. Use Text.Replace with Character.FromNumber(160) when that is the character you identified.