power query Replace Values - to hyphen or not to hypen?

ajm

Well-known Member
Joined
Feb 5, 2003
Messages
2,056
Office Version
  1. 365
Platform
  1. Windows
I was looking for a method to replace all entries in a particular column with a static statement. i found several different posts on different sites about how to do it. The simplest by far is here:


however, i could still not get it to work with my column until i removed a hyphen in the name. My column was titled "Test - Names" and this wasn't recognised until i removed the spaces and hyphen and named it "TestNames". The example in the link above has a space in the column name so it has to be the hyphen.

Am i correct in thinking the hyphen is an issue?

with the hyphen:

= Table.ReplaceValue(#"Changed Type",each [Test - Names],"Performance Review",Replacer.ReplaceText,{"Test - Names"})

Expression.SyntaxError: Invalid identifier.

Without the hyphen, all is golden.
= Table.ReplaceValue(#"Changed Type",each [TestNames],"Performance Review",Replacer.ReplaceText,{"TestNames"})
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
You'd need to use [#"Test - Names"]
 
Upvote 0
Solution
Thanks Rory. i have used:

= Table.ReplaceValue(#"Changed Type",each [#"Test - Names"],"Performance Review",Replacer.ReplaceText,{"Test - Names"})

I have two blank entries left that i was wanting to change to the same thing also. Essentially, replace each cell (blank or otherwise) in the column Test-Names with Performance Review. Does this need to be done separately to replacing the names in the column, or can it be included in the line above?

cheers
 
Upvote 0
Just use Replacer.ReplaceValue instead of Replacer.ReplaceText
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top