top of page
9d657493-a904-48e4-b46b-e08acb544ddf.png

POSTS

Power Query: Remove Special Characters from Text

Updated: Feb 24



PRACTICE MATERIAL BELOW!👇


Function: This function, RemoveSpecialChars, cleans a text string by removing special characters, retaining only letters and numbers.

Power Query screen with "Query1" open in Advanced Editor. Code shown removes specific symbols from text. Office toolbar above.
Add fx to the blank query (Advanced Editor)

Usage Example: 

Using = RemoveSpecialChars("H3ll0! W@rld#") will return "H3ll0 Wrld". The function removes 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



Excel Power Query interface showing a custom function dialog. A list of company names appears, with a green highlight on "Invoke Custom Function."
Invoke function on desired column

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

Rated 0 out of 5 stars.
No ratings yet

Add a rating
Page Logo

Turn Messy Data into Clear Dashboards and Better Decisions.

Contact

Address:
83022 Rosenheim, Germany

Join Our Newsletter

Get a free Power Query cheat sheet by subscribing!

© Excelized. All rights reserved.

bottom of page