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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

replacing values based on another column using M

Hi all, I'm trying to replace some incorrect values in column A based on the values in column B. Essentially, I would like to change all of the values in Column A to "127" IF Column B = "table" without adding a new column.

 

I've tried to use the Replacer.ReplaceText and Table.ReplaceValue functions but can't seem to get it right. Appreciate the help

 

Current table

Column AColumn B
124table
124table
125table

 

Desired table

Column AColumn B
127table
127table
127table
1 ACCEPTED SOLUTION

image.pngUsing → https://www.biinsight.com/quick-tips-conditionally-replace-values-based-on-other-values-in-power-que... as an example

 

Table.ReplaceValue(#"Changed Type", each [Column A], each if [Column B] = "table" then 127 else [Column A], Replacer.ReplaceValue,{"Column A"})

 

 






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



View solution in original post

3 REPLIES 3
ChrisMendoza
Resident Rockstar
Resident Rockstar

image.png

= Table.AddColumn(#"Changed Type", "Custom", each if [Column B] = "table" then Replacer.ReplaceValue([Column A],[Column A],127) else [Column A])





Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



Anonymous
Not applicable

Hey @ChrisMendoza, I appreciate the help here. However I'd like to find out a solution that does not require adding a new column. Thanks!

image.pngUsing → https://www.biinsight.com/quick-tips-conditionally-replace-values-based-on-other-values-in-power-que... as an example

 

Table.ReplaceValue(#"Changed Type", each [Column A], each if [Column B] = "table" then 127 else [Column A], Replacer.ReplaceValue,{"Column A"})

 

 






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors