Forum Discussion

Mic1979's avatar
Mic1979
Post Partisan
2 years ago
Solved

Replacing values in two columns simultaneously under condition

Dear all,   Up to now I have replaced values in one column based on a condition. Now I am trying to replace the values in two columns simulaneously vie the following function:   let RULE_8 = (I...
  • ahadkarimi's avatar
    2 years ago

    Hey Mic1979 , try and let me know if there is any problem.

    let
        RULE_8 = (Input_Table as table, Product_Series_Description as text) =>
        Table.TransformColumns(
            Input_Table,
            {
                {"Body_Material", each if [Product_Series_Description] = "2 way Angle Body Valve" and
                    ([Body_Material] = "Bronze" or [Body_Material] = "StSt 316L") and
                    ([Stuffing_Box_Material] = "StSt 431" or [Stuffing_Box_Material] = "StSt 316L")
                then "StSt 316L" else _},
                {"Stuffing_Box_Material", each if [Product_Series_Description] = "2 way Angle Body Valve" and
                    ([Body_Material] = "Bronze" or [Body_Material] = "StSt 316L") and
                    ([Stuffing_Box_Material] = "StSt 431" or [Stuffing_Box_Material] = "StSt 316L")
                then "StSt 431" else _}
            }
        )
    in
        RULE_8