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

Bulk replace text without custom function or tables

I've read a lot of posts about how to perform multiple value replacements in a column without resorting to the inefficient use of multiple single replacement steps which in my case was causing over 15 minutes to apply a change in power query due to millions of rows.

Most of the solutions I found use custom functions, lists or switch tables, all of which work but seemed more complicated than I needed.

I was playing around with M query and the solution below works for me.

I used the GUI to create the first replacement, then extended it out to include other criteria.

The example below uses Replacer.ReplaceValue so will match against the whole cell value.

To match against any portion of a cell value change to Replacer.ReplaceText

The part I like about this is you can also use it for replacement based on a value in a different column to the one you are performing (e.g. replace value in column 1 based on value in column 2 in same row) the replacement on by just changing the column heading after the if statement.

E.g:

#"Replaced Values in Column1" = Table.ReplaceValue(Source, each [Column1],
each if [Column1]="i spelt this uncorrectly" then "This is how to spell it"
else if [Column1]="i really can't type well" then "This is how to type well"
else if [Column1]="i want to use a custom power query function" then "I do not want to use a custom PQ function if I can avoid it!else [Column1], Replacer.ReplaceValue,{"Column1})

1 REPLY 1
Greg_Deckler
Community Champion
Community Champion

Nice!


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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