Replace multiple values in single column in one step in Power query

muthuji

New Member
Joined
Jan 26, 2022
Messages
3
Office Version
  1. 2016
Platform
  1. Windows
Dear All,
I am new to Power Query and want to replace multiple values in a single step by editing the M code for the replacement step.

97° 36' 30.5" (?)

In the above value I want to replace the "°" and "(?)" in single step.

and my step code is following:

= Table.ReplaceValue(#"Renamed Columns4","°","",Replacer.ReplaceValue,{"Latitude - Copy"})

Please guide.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Power Query:
Table.TransformColumns(#"Renamed Columns4", {"Latitude - Copy", each Text.Replace(Text.Replace(_,"°",""),"(?)","" )})
 
Upvote 0
Solution
Dear JGordon11, I am grateful to you for the solution.
Can I get two more solutions in the same step as follows:

1) 97° 36' 30.5" (?) : What will be the code for replacing all the Green characters viz"°" , " ' ", and " "(?)" in a single step.

2) Can we split this column in the same code with "SPACE" as a delimiter?
 
Upvote 0
Power Query:
Table.TransformColumns(#"Renamed Columns4", {"Latitude - Copy", each Text.Replace(Text.Replace(_,"°",""),"(?)","" )})
Dear JGordon11, I am grateful to you for the solution.
Can I get two more solutions in the same step as follows:

1) 97° 36' 30.5" (?) : What will be the code for replacing all the Green characters viz"°" , " ' ", and " "(?)" in a single step.

2) Can we split this column in the same code with "SPACE" as a delimiter?
 
Upvote 0
Power Query:
= Table.AddColumn(Source,"new",each List.Accumulate({"°","'",""" (?)"},[Data],(x,y)=>Text.Replace(x,y,"")))
1645362043573.png

Power Query:
= Table.AddColumn(Source,"new",each Text.Split(List.Accumulate({"°","'",""" (?)"},[Data],(x,y)=>Text.Replace(x,y,""))," "))
1645362099457.png
 
Upvote 0

Forum statistics

Threads
1,223,674
Messages
6,173,746
Members
452,533
Latest member
Alex19k

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