cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
nirvana_moksh Established Member
Established Member

Effective way to remove inner spaces in columns

Hello All,

 

I was wondering how do you handle removing of inner spaces in a column which has values like:

 

USA; CHICAGO

USA:  CHICAGO

USA:     CHICAGO

 

 

In M I did a Text.Split on space and then Text.Combine, but just thinking if that is effective and the best way to handle this situation or not?

 

 

Thank You

2 ACCEPTED SOLUTIONS

Accepted Solutions
Super User
Super User

Re: Effective way to remove inner spaces in columns

    #"Replaced Value" = Table.ReplaceValue(#"Changed Type"," ","",Replacer.ReplaceText,{"Country"})

Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!


Community Support Team
Community Support Team

Re: Effective way to remove inner spaces in columns

@nirvana_moksh,

 

Yes, see code below.

Column =
SUBSTITUTE ( Table1[Column1], " ", "" )
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
4 REPLIES 4
Super User
Super User

Re: Effective way to remove inner spaces in columns

    #"Replaced Value" = Table.ReplaceValue(#"Changed Type"," ","",Replacer.ReplaceText,{"Country"})

Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!


Community Support Team
Community Support Team

Re: Effective way to remove inner spaces in columns

@nirvana_moksh,

 

By the way, you may also use SUBSTITUTE in DAX.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
nirvana_moksh Established Member
Established Member

Re: Effective way to remove inner spaces in columns

@v-chuncz-msft - will this handle multiple space issues? Like sometimes its a double space, or three spaces or more?

Community Support Team
Community Support Team

Re: Effective way to remove inner spaces in columns

@nirvana_moksh,

 

Yes, see code below.

Column =
SUBSTITUTE ( Table1[Column1], " ", "" )
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.