A critical part of data preparation is data cleansing. When it comes to data cleansing, replacing values is one of the most common transformation activities we perform. A simple example is where we have a description column in which the users of the source system enter free text data, and we would like to replace some part of the description with something else.
When we use the Power Query Editor UI to replace a value in a table, it uses the
Table.ReplaceValue(table as table, OldValue as any, NewValue as any, Replacer as function, columnsToSearch as list) function behind the scenes. If we want to replace the value of a
List, it uses the
List.ReplaceValue(list as list, OldValue as any, NewValue as any, Replacer as function) function. Depending on the value's data type that we want to replace, the
Replacer function can be either
Replacer.ReplaceValue. The difference between the two is that we can use
Replacer.ReplaceText to replace text...