Forum Discussion

zvm's avatar
zvm
Icon for Helper II rankHelper II
8 years ago
Solved

Power Query - update column

Hi, Is it possible to update column with Power Query ("M") like with SQL update command?   Here is the situation: - one column is free text where I need to search for a certain patterns (1, 2 or ...
  • v-yulgu-msft's avatar
    8 years ago

    Hi zvm,

     

    If there is no existing [prod_code] field in source table and you are trying to insert a new one, please add a custom column like this:

    =if Text.Contains([description],"70") and Text.Contains([description],"400") and [cat_code]="A" then "A5" else if Text.Contains([description],"agg") and Text.Contains([description],"40") and [cat_code]="A" then "A2" else if Text.Contains([description],"25") and [cat_code]="B" then "B2" else " "

     

    If there is already an esisting [prod_code] field and you want to update its value with correct prod numers, please add a further step based on above change.

    #"Replaced Value" = Table.ReplaceValue(#"Added Custom",each [prod_code], each [Custom] , Replacer.ReplaceText,{"prod_code"})
    

     

    Best regards,

    Yuliana Gu