cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tweidner
Helper I
Helper I

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:

 

tweidner_0-1619160095198.png

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. 

 

tweidner_1-1619160236565.png

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

 

Any ideas?

 

Thank you & Rgds
Tobias

1 ACCEPTED SOLUTION
CNENFRNL
Super User III
Super User III

@tweidner 

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

View solution in original post

2 REPLIES 2
tweidner
Helper I
Helper I

@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

CNENFRNL
Super User III
Super User III

@tweidner 

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

View solution in original post

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Kudoed Authors