Text.BeforeDelimiter

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.

emails dataset

We need to write the following formula to extract our desire results.

Text.BeforeDelimiter([Emails],"@")

we will get the following result.

text.beforedelimiter power query function

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)
Text.beforedelimiter power query function for multiple delimiters

If you have multiple delimiters, use the third parameter; otherwise, you can skip it.

To learn more, please visit Learn DAX

Similar Posts