Forum Discussion

leahschneider's avatar
leahschneider
Helper III
4 years ago
Solved

Replace Value in Multiple Columns Conditionally

I have a table in Power Query and I need to replace values across multiple columns if one column has a particular value. I've used https://gorilla.bi/power-query/replace-values/#conditional-replace-single-step and it seems sort of helpful but I want to replace the value based on the value in the table and not just to a static number.

To use the example in that website...

Instead of this:

 

= Table.ReplaceValue(
#"Removed Other Columns",
each [Income] > 50000,
each 2,
(x,y,z)=> if y then z else x,
{"Kidhome", "Teenhome"}
)

I need:

= Table.ReplaceValue(
#"Removed Other Columns",
each [Income] > 50000,
each [whatever the value is in the column] * 2,
(x,y,z)=> if y then z else x,
{"Kidhome", "Teenhome"}
)

 

Can anyone help?

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi leahschneider 

     

    have a try

    = Table.ReplaceValue(
    #"Removed Other Columns",
    each [Income] > 50000,
    null,
    (x,y,z)=> if y then x*2 else x,
    {"Kidhome", "Teenhome"}
    )

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi leahschneider 

     

    have a try

    = Table.ReplaceValue(
    #"Removed Other Columns",
    each [Income] > 50000,
    null,
    (x,y,z)=> if y then x*2 else x,
    {"Kidhome", "Teenhome"}
    )