Text.BeforeDelimiter Power Query function
Text.beforedelimiter is a power query function that returns the substring before a specific delimiter. It helps us to clean the data before importing it into Power BI.
Syntax
Text.BeforeDelimiter(Given string, Delimiter as text, Optional Index)
Text.BeforeDelimiter takes three parameters. The first two parameters are compulsory, and the third parameter is optional.
- The first parameter is the given string.
- The second parameter is the delimiter.
- The third parameter is the position of the delimiter, which we need to consider before extracting the substring.
Example
Let’s take the following example to extract the substring using text.beforedelimiter power query function.
We have the following email data and want to extract the user names before the “@” sign.
We need to write the following formula to extract our desire results.
Text.BeforeDelimiter([Emails],"@")
we will get the following result.
Text.BeforeDelimiter function for multiple delimiters
We have to use the third parameter if we have multiple delimiters and want to extract the text before a delimiter at a specific position.
Let’s take the same example of email addresses and try to fetch the text before the last delimiter that is point “.”.
We need to write the following formula.
Text.BeforeDelimiter([Emails],".",1)
If you have multiple delimiters, use the third parameter; otherwise, you can skip it.
To learn more, please visit Learn DAX