OpenBI Docs Buy

Text.BeforeDelimiter

What comes before a delimiter in a text: before its first occurrence, or before the one you choose.

Group: Text and characters. Power Query M has it too: a query that uses it is written as in Power BI.

Syntax

Text.BeforeDelimiter(text as nullable text, delimiter as text, optional index as any) as any
ParameterTypeDescription
textnullable textThe text to work on; null gives null.
delimitertextThe text to look for.
indexany
optional
Which occurrence of the delimiter to use, counted from 0; or a list {index, RelativePosition.FromEnd} to count from the end of the text. Left out, the first one.

Returns

any. The text up to the delimiter; the whole text when the delimiter isn't there.

Remarks

  • The search is exact: case counts.

Examples

The country code

Text.BeforeDelimiter("NO-0150-Oslo", "-")
"NO"

Up to the last dash

Text.BeforeDelimiter("NO-0150-Oslo", "-", {0, RelativePosition.FromEnd})
"NO-0150"

No delimiter in the text

Text.BeforeDelimiter("NO-0150-Oslo", "/")
"NO-0150-Oslo"

The whole text comes back.

Text.AfterDelimiter, Text.BetweenDelimiters, Text.Start, Text.Split.

Last updated · OpenBI Studio 0.3.79