While Power Query has a native function to fetch text between 2 delimiters in Power Query, there is no such function that removes the text instead. Therefore I’ve created a custom function Text.RemoveBetweenDelimiter. It even lets you choose to remove the delimiters themselves as well via the optional 4th parameter. (“Text.RemoveBetweenDelimiters “- function)
The code for the Text.RemoveBetweenDelimiters -function
How to use
The Text.RemoveBetweenDelimiters – function has 3 mandatory parameters and an optional one:
- Text itself (as text)
- first delimiter (as text, can contain multiple characters)
- second delimiter (as text, again can contain multiple characters)
- optional string: Any value you enter here, will remove the delimiters themselves as well
- Delete HTML-tags like so:
Text_RemoveBetweenDelimiters(YourHtml, "<", ">", 1)
- Delete multiline comments from DAX- or M-code (like I’ve done here for example).
Text_RemoveBetweenDelimiters(YourDAXorMQuery, "/*", "*/", "yes")
So once you enter any value into the fourth parameter, the delimiters themselves will be removed as well.
Enjoy and stay queryious 😉