Forum Discussion

brigittagemes's avatar
6 years ago
Solved

Power Query custom function to replace multiple values in a column

Hi,   I'm tryiing to create a custom function to find and replace values, all in one step. I really would love to solve this problem without an extra table or DAX SWITCH.   Sample file here   O...
  • mahoneypat's avatar
    6 years ago

    You need to refer to the previous step in each step.  Your last step starts with myFruit, so only it is executed.  See modified function below:

     

    (myFruit as text) =>
    
    let
    
    #"Replace a" = Replacer.ReplaceValue(myFruit, "a","apple"),
    #"Replace b" = Replacer.ReplaceValue(#"Replace a", "b","banana"),
    #"Replace l" = Replacer.ReplaceValue(#"Replace b", "l","lemon")
    
    in
    
    #"Replace l"

     

    If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

    Regards,

    Pat