Forum Discussion
Custom Power Query Function to replace a Text in a column base on conditions
- 2 years ago
Finally I found the solution:
let
Change_Text_Column=(Input_Table as table) =>
Table.ReplaceValue (
Input_Table,
each [#"Text"],
each if [#"Text"]="3" then "12"
else [#"Text"],
Replacer.ReplaceText,
{"Text"})in Change_Text_Column
This is the results obtained invoking the function:
Start Text
3 12
4 4
5 5
7 7
9 9
The point for me now is to use it adding a column in a table adding a column.
It seems not possible to use as input parameter the same table where I want to add the column by invoking the function. I have an error message.
Thanks for your help.
Thanks a lot.
No I don't get any error message. I made this:
let
Change_Text=(Text) =>
Text.Replace (
Text,
"Text",
if Text="a" then "f"
else Text)
in Change_Text
However it seems that the condition is not working, and whatever text I insert, I have the same text as output.
Any suggestions?
Thanks in advance
Finally I found the solution:
let
Change_Text_Column=(Input_Table as table) =>
Table.ReplaceValue (
Input_Table,
each [#"Text"],
each if [#"Text"]="3" then "12"
else [#"Text"],
Replacer.ReplaceText,
{"Text"})
in Change_Text_Column
This is the results obtained invoking the function:
Start Text
3 12
4 4
5 5
7 7
9 9
The point for me now is to use it adding a column in a table adding a column.
It seems not possible to use as input parameter the same table where I want to add the column by invoking the function. I have an error message.
Thanks for your help.