Table.ReplaceValue Function in Power Query
The Table.ReplaceValue function replaces oldValue with newValue in specific columns of a table, using the provided replacer function.
Syntax
Table.ReplaceValue( table as table, oldValue as any, newValue as any, replacer as function, columnsToSearch as list, ) as table
Example:
Power Query M
let MyTable = Table.FromRecords( { [CustomerID = 1, Name = "Ashish", Phone = "123-4567", Company="TCS"], [CustomerID = 2, Name = "Katrina", Phone = "987-6543", Company="TCS"], [CustomerID = 3, Name = "Alia", Phone = "543-7890", Company="TCS"], [CustomerID = 4, Name = "Vicky", Phone = "676-8479", Company="TCS"], [CustomerID = 5, Name = "Mohini", Phone = "574-8864", Company="TCS"], [CustomerID = 6, Name = "Meenakshi", Phone = "574-8864", Company="TCS"], [CustomerID = 7, Name = "Esha", Phone = "574-8864", Company="TCS"], [CustomerID = 8, Name = "Anjali", Phone = "574-8864", Company="TCS"] } ), #"Return Value" = Table.ReplaceValue(MyTable, "TCS", "Tata", Replacer.ReplaceText, {"Company"}) in #"Return Value"
The output of the above code is shown below: