Text.End

Text

Returns a text value of the specified length from the end of a text value.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Text.End(text as nullable text, count as number) as nullable text

Parameters

NameTypeRequiredDescription
texttextYesThe source text value.
countnumberYesThe number of characters to return from the end of the text.

Return Value

textThe 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
Result
14567

Example 2: Extract a file extension from a filename

Text.End("Sales_Report_2024.xlsx", 4)
Result
Result
1xlsx

Example 3: Extract the numeric portion of employee IDs

Text.End("E003", 3)
Result
Result
1003

Example 4: Count exceeds text length — entire text is returned

Text.End("Hi", 10)
Result
Result
1Hi

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks