cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Solution Sage
Solution Sage

Power Query - Replace multiple substrings in one column

Hello,

 

I am looking for a solution to replace multiple substrings at once.

For Example:

CategoryCategory after
AA_AAB_A
aa_BAB_B
AA_CAB_C
BB_ADE_A
BB_BDE_B
BB_CDE_C

 

so AA->AB, aa->AB and BB->DE.

 

I found something here, but it is not able to replace substrings and it creates three single steps.

My aim would be to do it in one single step.

 

I'm really looking forward for your feedback.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Microsoft
Microsoft

Re: Power Query - Replace multiple substrings in one column

Hi @Floriankx,

 

Here are some blogs written about multiple replacements of words with Power Query:

Multiple replacements or translations in Power BI and Power Query

Multiple replacements of words in Power Query

Replace multiple values in a single step

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Highlighted
Microsoft
Microsoft

Re: Power Query - Replace multiple substrings in one column

Hi @Floriankx,

 

Here are some blogs written about multiple replacements of words with Power Query:

Multiple replacements or translations in Power BI and Power Query

Multiple replacements of words in Power Query

Replace multiple values in a single step

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Advocate I
Advocate I

Re: Power Query - Replace multiple substrings in one column

Hi, @Floriankx 

 

Try the following M formula in Query Editor:

 

Text.Combine( List.ReplaceMatchingItems(

Text.Split ([Category], ”_“), { {“AA”, “AB”} , {“aa”, ”AB“} , {“BB” , “DE” } }

))

 

Here is more information to assist you:
https://www.syntelli.com/easy-guide-to-bulk-replace-values-in-power-bi-or-power-query

 

Let me know if it works!

Helpful resources

Announcements
Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors