Share via

Replace multiple text.strings in one PowerQuery step

Anonymous
2024-11-03T05:34:31+00:00

Problem statement:

I would like to replace multiple values within a text string only if found, all in one step.

Example:

In my column of 8000 rows, I want to replace @ symbol with *40 in text string like ******@email.org and then I want to replace "Org" to "Com", then I want to replace CP-ZI with CP-PREF-ZI only if the text begins with CP-ZI I want to replace CP-ZE with CP-PREF-ZE only if the text begins with CP-ZE I want to replace CP-ZL with CP-PREF-ZL only if the text begins with CP-ZL

I have multiple values like this, that needs to be replaced for a given column. I want to be able to do all the replaces with one query, instead of creating multiple replace queries.

I do not want to replace the entire cell content. Only a partial text string, like shared in the above example.

Please help me build a M query that will solve this.

My column looks something like this:

******@TESTER2.org

******@TESTME.org

******@SUMMER.org#IN@E

ACEEML/INV/******@DOMAIN.org

QI 9 E S*/******@SUMMER.org

******@TESTER2.org

******@TESTME.org

******@TESTME.org

******@MX.org

CP-ZL-Y@OPTL

CP-ZE-Y@OPTL

CP-ZL-JFK@LGA@EWR

CP-ZE-SFO@OAK

CP-ZL-DCA@IAD

CP-ZE-ORD@MDW/DFW@DAL/IAH@HOU

CP-ZI-FIRST PREFERRED AA@DL@UA@B6@WN@AS@VA

CP-ZI-AM@AA@AV@DL@UA

CP-ZI-TESTBEST

******@AMEXGBT.org

******@SUMMER.org#IN@E

CP-ZE-TESTBEST

CP-ZL-TESTBEST

QI 9 E MARTIN_******@JIO-DAD.org

******@TESTER2.org

******@TESTME.org

******@SUMMER.org#IN@E

Microsoft 365 and Office | Excel | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Andreas Killer 144.1K Reputation points Volunteer Moderator
    2024-11-03T08:10:58+00:00

    Can you please share your file and write your request in an additional sheet?

    Most of your post has been anonymized by the forum editor.

    Andreas.

    Was this answer helpful?

    0 comments No comments