Forum Discussion

Mic1979's avatar
Mic1979
Post Partisan
2 years ago
Solved

Custom Power Query Function to replace a Text in a column base on conditions

Dear all,   I am approaching in these days to the customized function in Power Query, I am really new and not familiar with this topic. My target is to reaplace a value in a column table based on ...
  • Mic1979's avatar
    Mic1979
    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.