Power Query: Remove Special Characters from Text
- MirVel
- Mar 13
- 1 min read
Updated: May 28
Function: This function, RemoveSpecialChars, cleans a text string by removing special characters, retaining only letters and numbers.

Usage Example:
Using = RemoveSpecialChars("H3ll0! W@rld#") will return "H3ll0 Wrld". The function operates by removing specified special characters from the input text, ensuring a clean output.
Power Query code for use and reuse:
RemoveSpecialChars = (inputText as text) as text =>
let
CleanedText = Text.Remove(inputText, {"!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "-", "_", "=", "+", "[", "]", "{", "}", ";", ":", "'", ",", ".", "<", ">", "/", "?", "|", "\"})
in
CleanedText
in
RemoveSpecialChars

This is the M-code that Power Query usually makes on every step that we do:
= Table.AddColumn(#"Added Conditional Column", "Query1", each Query1([Customer]))
Need code and instructions? Free of charge =)
Comments