Forum Discussion

jonclay's avatar
jonclay
Icon for Helper IV rankHelper IV
2 years ago
Solved

Trying to change multiple values in one step

Hi everyone I'm using the following code in an attempt to change multiple values all in one step: = Table.ReplaceValue( #"Renamed Columns", each [Type], each if [Type] = "157420000" then "A" ...
  • parry2k's avatar
    2 years ago

    jonclay here is what you can do, create a new blank query -> click advanced editor and paste the following M code, call this new query fnGetType (you can use whatever name you want)

     

    (value) =>
    let
    
        valueToList = Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv)(value),
        valueToType = Text.Combine(List.Transform(valueToList, each if _ = "157420000" then "A" else if _ = "157420002" then "B" else "C"), "," )
        
    in
        valueToType

     

    now add a new column in your table with the following expression

     

    fnGetType([Type])