Forum

Replace values that...
 
Notifications
Clear all

Replace values that contain a quotation mark

4 Posts
3 Users
0 Reactions
284 Views
(@kjbox)
Posts: 69
Trusted Member
Topic starter
 

I have text in a column named "name", for example

RPG Notebook 5"x8"

I need to replace Notebook 5"x8" with N58

I am struggling to get the syntax right because of the quotation marks in the original text.

= Table.ReplaceValue(#"Replaced Value3","Notebook 5"x8"","- N58",Replacer.ReplaceText,{"name"})

returns

Expression.SyntaxError: Token ',' expected.

Any help greatly appreciated.

 
Posted : 14/07/2024 6:48 pm
Alan Sidman
(@alansidman)
Posts: 223
Member Moderator
 

This worked for me.

 

let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Replaced Value" = Table.ReplaceValue(Source,"Notebook 5""x8""","N58",Replacer.ReplaceText,{"name"})
in
#"Replaced Value"

 
Posted : 15/07/2024 12:17 am
Riny van Eekelen
(@riny)
Posts: 1201
Member Moderator
 

When I follow your scenario, and just by clicking in the user interface, the M-code looks like this:

Table.ReplaceValue(Source, "Notebook 5""x8""", "- N58", Replacer.ReplaceValue, {"name"})
 
Note that there are some double quote marks missing in your code.
 
Posted : 15/07/2024 12:18 am
(@kjbox)
Posts: 69
Trusted Member
Topic starter
 

Thanks Alan & Riny,

Tried those solutions but text was not replaced.

Finally got it to work with

Table.ReplaceValue(#"Replaced Value3","Notebook 5”x8”","N58",Replacer.ReplaceText,{"name"})

Seems like the double quotes after the 5 & 8 were not the same as normal double quotes, nor were they 2 single quotes!

I selected a Notebook in the name column then copied the Notebook 5"x8" bit in the Preview Pane and pasted that into the M-Code, after that everything worked fine.

The Source file is actually a CSV file downloaded from a web site which is then converted to an .xlsx file, maybe that accounts for the strange double quotes.

 
Posted : 15/07/2024 4:31 am
Share: