cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
HxH Regular Visitor
Regular Visitor

Replacing multiple values with a switch-like function in M

Hi everyone, 

I am currently replacing values in Power Query and I would like to know how I can replace a bunch of them using a single function, reproducing a behaviour similar to the DAX SWITCH function 

#"Replaced Value1" = Table.ReplaceValue(#"Filtered rows","Clio-2016","Clio",Replacer.ReplaceText,{"Model"}),
#"Replaced Value2" = Table.ReplaceValue(#"Replaced Value1","Kuga-2016","Kuga",Replacer.ReplaceText,{"Model"})
in 
#"Replaced Value2"

 

I have copied the last two rows of my advanced editor so that you have a reference to use with my data. As you can see I did the clio and the kuga replacement in two different steps but I would like to do both in one (I have to do like a hundred of these, so I want a faster way than having to manually replace all the values with the button)

Also nevermind the fact that I have removed "-2016" in both, it is just a coincidence. The data have very different formats and I can't to a trim or a split by delimiter. 

1 ACCEPTED SOLUTION

Accepted Solutions
mcybulski Member
Member

Re: Replacing multiple values with a switch-like function in M

This issue is a common theme addressed by many bloggers. Here is one.

 

https://www.howtoexcel.org/power-query/bulk-replace-values/

View solution in original post

1 REPLY 1
mcybulski Member
Member

Re: Replacing multiple values with a switch-like function in M

This issue is a common theme addressed by many bloggers. Here is one.

 

https://www.howtoexcel.org/power-query/bulk-replace-values/

View solution in original post

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Ask Amanda Anything Q&A

Ask Amanda Anything Q&A

Learn the answers to some of the questions asked during the Amanda Triple A event.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Top Kudoed Authors
Users Online
Currently online: 427 members 3,577 guests
Please welcome our newest community members: