Text.End
TextReturns a text value of the specified length from the end of a text value.
Syntax
Text.End(text as nullable text, count as number) as nullable textParameters
| Name | Type | Required | Description |
|---|---|---|---|
text | text | Yes | The source text value. |
count | number | Yes | The number of characters to return from the end of the text. |
Return Value
text — The last count characters of text.
Remarks
Text.End extracts a substring from the end of a text value, returning the last count characters. It is the right-side counterpart to Text.Start, and together they cover the most common fixed-length extraction patterns.
If text is null, the function returns null. If count is greater than the length of text, the entire text is returned without error — this differs from list indexing, which raises an error on out-of-range access. If count is 0, an empty string is returned.
Use Text.End when the trailing portion of a string has a known fixed length (file extensions, phone number suffixes, date components, ID suffixes). When the suffix is variable-length and delimited by a separator, Text.AfterDelimiter with {0, RelativePosition.FromEnd} is more appropriate. For extracting from the middle of a string, use Text.Middle or Text.Range.
Examples
Example 1: Extract the last four digits of a phone number
Text.End("(555) 123-4567", 4)Result | |
|---|---|
| 1 | 4567 |
Example 2: Extract a file extension from a filename
Text.End("Sales_Report_2024.xlsx", 4)Result | |
|---|---|
| 1 | xlsx |