Forum Discussion

tweidner's avatar
tweidner
Helper I
5 years ago
Solved

Power Query, M Code, Replace Value based on value in another column

Hello Everybody,

 

Apologies in case this was answered already in this forum, but I wasn't able to find it...

 

I've one column (Division) in a table where I would like to change the value if a value in another column (Country) fulfills a criteria.

 

Looks like:

 

Value in [Division] should change to "Offshore", if value in column [Country] = "Oman"

 

I thought I was close with the following formula, but nothing happens. 

 

= Table.ReplaceValue(#"Changed Type", each [Country] = "Oman" , "Offshore" ,Replacer.ReplaceValue,{"Division"})

 

Any ideas?

 

Thank you & Rgds
Tobias

  • tweidner 

    Table.ReplaceValue(#"Changed Type", each if [Country] = "Oman" then "Offshore" else [Division], null, (x,y,z) => y, {"Division"})

2 Replies

  • CNENFRNL's avatar
    CNENFRNL
    Community Champion

    tweidner 

    Table.ReplaceValue(#"Changed Type", each if [Country] = "Oman" then "Offshore" else [Division], null, (x,y,z) => y, {"Division"})
  • CNENFRNL Thanks for the quick response... I would highly appreciate if you could explain the ,null, (x,y,z) => y 

    piece...

     

    Is this just filling the formula requirement?

     

    Rgds
    T