Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

To replace a word within a sentence/string in Power Query

I am trying to use excel power query to replace a word in a sentence.

For example, I would like to replace "South Korea" to "Korea"

Original:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

ID Primary Location Other Locations
001 United States South Korea, Japan
002 United Kingdom France, United States, South Korea
003 France United Kingdom
004 Australia Japan
005 Japan South Korea

After Power Query:

ID Primary Location Other Locations
001 United States Korea, Japan
002 United Kingdom France, United States, Korea
003 France United Kingdom
004 Australia Japan
005 Japan Korea

I tried to use the

Table.ReplaceValue(#"Step1","South Korea","Korea",Replacer.ReplaceText,{"Other Locations"})

But it only gave me

ID Primary Location Other Locations
001 United States South Korea, Japan
002 United Kingdom France, United States, South Korea
003 France United Kingdom
004 Australia Japan
005 Japan Korea

Are there ways that I can replace all the "South Korea" to "Korea" within the same column?

Thank you.

>Solution :

your syntax is perfect

= Table.ReplaceValue(#"Step1","South Korea","Korea",Replacer.ReplaceText,{"Other Locations"})

that means you have another error somewhere

(a) You sample columns says "Other Locations" your formula says "Other Location". They are not the same

(b) Maybe #"Step1" is not the name of the original data. Are you sure?

Right click the column and use replace text option. It will write the code for you

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading