cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Floriankx
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
v-yulgu-msft
Microsoft
Microsoft

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
Anonymous
Not applicable

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!

v-yulgu-msft
Microsoft
Microsoft

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.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors