Text.BeforeDelimiter
Text function · By Tahir Nas · Examples run in our simulator · Published · Updated
Returns the text before a delimiter.
When to use it
Use it to take the part of a value before a separator: the user part of an email, the code before a dash, the date part of a timestamp. It works for any length, unlike fixed-position extraction.
Syntax
Text.BeforeDelimiter(text as nullable text, delimiter as text, optional index as any) as anyParameters
- index
- Which occurrence to use (0-based), or {index, RelativePosition.FromEnd}.
Returns
The text before the delimiter.
Example
Text.BeforeDelimiter("ana.silva@firm.example", "@")Result
ana.silva
Example: before the last delimiter
{0, RelativePosition.FromEnd} picks the last occurrence.
Text.BeforeDelimiter("2026-Q1-North", "-", {0, RelativePosition.FromEnd})Result
2026-Q1
Both results are produced by the Power Query Exercises simulator, an independent implementation of a documented subset of M, and checked on every build.
Good to know
- Returns the whole text if the delimiter is missing.
Common mistakes
- Assuming a missing delimiter gives null: you get the whole text.
- Counting occurrences from 1; the index is 0-based.
The matching command in Excel
- Excel for Windows
- Add Column > Extract > Text Before Delimiter
- What you see
- A new column holds the text before the delimiter you enter; the original stays.
Paths are for the Power Query editor in Excel for Microsoft 365, checked against Microsoft's documentation on 8 November 2026: Add a column based on a data type (Power Query) (Microsoft Support).
Exercises that use Text.BeforeDelimiter
Learn more
- Split columns and extract text by delimiter lesson
- Power Query text functions cheat sheet (tested) guide
- Split column recipes: names, codes, addresses and lists guide
Related functions
Official documentation: Text.BeforeDelimiter on Microsoft Learn.