Text.End

Updated on

Text.End is a Power Query M function that extracts the last specified number of characters from a text value. The function returns a text value containing the last count characters of the input text.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

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

Description

Returns a text value that is the last count characters of the text value text. It enables you to specify the desired number of characters to extract from the end of a text string.

Examples

Let’s dive into some examples to illustrate the usage of the Text.End function:

Suppose you have the text string “Hello, World” and you want to extract the last 5 characters. By utilizing the Text.End function with the text “Hello, World” and a count of 5, you will obtain “World” as the resulting extracted substring.

Text.End( "Hello, World", 5 ) // Returns "World"

Consider the phrase “Life is good.” If you need to extract the last 4 characters from this text, you can use the Text.End function with the text “Life is good” and a count of 4. This will yield “good” as the extracted substring.

Text.End( "Life is good", 4 ) // Returns "good"

In some cases, you may want to extract a longer substring from the end of a text value. For instance, if you have the text “Life is good” and want to retrieve the last 7 characters, Text.End with the text “Life is good” and a count of 7 will give you “is good” as the resulting extracted substring.

Text.End( "Life is good", 7 ) // Returns "is good"

Learn more about Text.End in the following articles:

Other functions related to Text.End are:

BI Gorilla Blog

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/text-end