Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Removing special characters and symbols from a column

Hi there,

 

I have a Country Column with all sorts of weird and wonderful things such as 

CÔTE D'IVOIRE

 and 

SAINT BARTHÉLEMY

 

and I want to remove all the accents etc. I tried Format>Clean but that hasn't helped. Any idea?

2 ACCEPTED SOLUTIONS
dax
Community Support
Community Support

Hi heytherejem,

Did you want to het result like below

365.PNG

You could try below M code

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcj48JcRVwSWm1MDAyNwzzN8zyFUpVidayTMvJTMRzAp29PQLUXByDArxONzp4+obqRQbCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"country name" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"country name", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Text.Select([country name],{"a".."z","A".."Z","0".."9"," "})),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"country name"})
in
    #"Removed Columns"

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

Anonymous
Not applicable

Hi @dax  Zoe Zhi, your custom column has removed the letter as well as the special character so not quite what I need. I have used find and replace to get the result I need, but I just feel this is quite manual and you have to have a separate step for each find/replace (urgh). 

However your solution will probably work for me in a different situation so it's really useful to see the logic!

 

Thanks 🙂 

Jemma

View solution in original post

4 REPLIES 4
dax
Community Support
Community Support

Hi heytherejem,

Did you want to het result like below

365.PNG

You could try below M code

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcj48JcRVwSWm1MDAyNwzzN8zyFUpVidayTMvJTMRzAp29PQLUXByDArxONzp4+obqRQbCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"country name" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"country name", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Text.Select([country name],{"a".."z","A".."Z","0".."9"," "})),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"country name"})
in
    #"Removed Columns"

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

mapr
Frequent Visitor

This is a very useful solution, thanks.

Anonymous
Not applicable

Hi @dax  Zoe Zhi, your custom column has removed the letter as well as the special character so not quite what I need. I have used find and replace to get the result I need, but I just feel this is quite manual and you have to have a separate step for each find/replace (urgh). 

However your solution will probably work for me in a different situation so it's really useful to see the logic!

 

Thanks 🙂 

Jemma

dax
Community Support
Community Support

Hi heytherejem, 

Thank you for your sharing! If this helps you and if you'd like to, you could mark corresponding post as answer or share your solutions. That way, people who in this forum and have similar issue will benefit from it.

Thanks for your understanding and support.
Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.