Forum Discussion
Replace values between square brackets in a Query
- 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
Position should be at the end, but maybe not always. Splitting a column at a delimiter then deleting the one I dont need seems like overkill?
M is new to me but I can code like half a dozen other languages to varying degrees of proficiency - its just a matter of learning the syntax and how to read the docs, right?
I feel like I'm super close with this, but how do I dynamically get the old value?
= Table.ReplaceValue(#"Replaced Value1",Text.BetweenDelimiters(*** OLD VALUE ***,"[","]"),"",Replacer.ReplaceText,{"Email Name V2"})
https://docs.microsoft.com/en-us/powerquery-m/text-betweendelimiters
https://docs.microsoft.com/en-us/powerquery-m/table-replacevalue
- HotChilli7 years ago
Community Champion
You'll probably need an 'each' and a column reference in there.
I'm not sure why you think the split column idea is overkill. It takes about 2 seconds to do it in the Power Query editor.