Text.BeforeDelimiter

This function retrieves the text before a specified delimiter. It includes optional parameters to specify which occurrence of the delimiter should be used and whether the indexing should start from th...

Syntax

Text.BeforeDelimiter(text as nullable text, delimiter as text, optional index as any) as any

About

This function retrieves the text before a specified delimiter. It includes optional parameters to specify which occurrence of the delimiter should be used and whether the indexing should start from the beginning or end of the input.

Explanation

Retrieve the section of text "111-222-333" that comes before the first hyphen by using the Power Query MText.BeforeDelimiter("111-222-333", "-") function. The output will be "111". To obtain the section of text "111-222-333" before the second hyphen, use the Power Query MText.BeforeDelimiter("111-222-333", "-", 1) function. The output will be "111-222". For retrieving the section of text "111-222-333" before the second hyphen from the end, use the Power Query MText.BeforeDelimiter("111-222-333", "-", {1, RelativePosition.FromEnd}) function. The output will be "111".