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
logo

Transform your data with our data analytics services! From Excel to Power BI with Power Query in the background, drive your business forward!

  • Linkedin
  • Xing
  • RSS
  • 4844455

Contact Us

Address:
83022 Rosenheim, Bavaria, Germany
Worldwide (online) available!

Join Us!

Stay updated with tips & tutorials!

© Excelized. All rights reserved.

bottom of page