Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Community Champion
Community Champion

@tweidner 

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

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

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
Community Champion
Community Champion

@tweidner 

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

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors