Identify and Replace Hidden Characters in Excel Power Query Text
Question details
Identify nonstandard space characters in API-imported text and replace them so matching values can be merged.

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

Check a Suspected Character with Excel UNICODE
Use an Excel formula to identify a character when you can isolate its position in a worksheet cell.
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.

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.




