Forum Discussion
Replace TEXT in a column using IF
- 4 years ago
Hi DanFromMontreal ,
You would use the standard Replace Values function from the transform tab on your column that you want values to be replaced in, but in the 'text to find' and 'replace with' boxes, you would just add random values, let's assume "aaa" and "bbb". This sets up the query step for you nicely.
You then edit the step something like this:
//Change your step that looks like this: = Table.ReplaceValue( previousStep, "aaa", "bbb", Replacer.ReplaceText,{"columnName"} ) //To something like this: = Table.ReplaceValue( previousStep, each [columnName], each if [columnName] = "A" then [columnA] else if [columnName] = "B" then [columnB] else if [columnName] = "C" then [columnC] else [columnName], Replacer.ReplaceText,{"columnName"} )If this doesn't seem to do anything, then change the last 'Replacer.ReplaceText' to 'Replacer.ReplaceValue'.
Pete
Hi DanFromMontreal ,
You want a function in power query that can be called multiple times, right?
I think this similar post will inspire you, see the Message 6. You'll need a Transformation Table and a function to call.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.