Forum Discussion
Anonymous
7 years agoNot applicable
Replace values between square brackets in a Query
Hi, PowerBI newbie here but loving it! In my Query I have a column where the values may have text in square brackets eg: This is some text [and this is other text] I would like to remove...
- 7 years ago
Hello,
If you just want to replace the value in the brackets you can create a new column (Add Custom Column option in Power Query) and use this code:
=Text.Replace([Column1], Text.BeforeDelimiter(Text.AfterDelimiter([Column1], "["), "]"), "")
The code replaces whatever it is found between brackets with empty string. You can change that according to your needs.
Regards,
ElenaN
OB
Helper II
4 years ago
How can this solution be adjusted to make multiple replacements in one text string?
My example simplified to make it as close to the above solution as possible: each time I have text in brackets (text in brackets will vary), I want to replace with space,
e.g. ABC [text1], EFG [text2], XYZ [text3] > ABC[ ], EFG[ ], XYZ [ ]
Thank you!