Share via


Text.TrimEnd

Syntax

Text.TrimEnd(text as nullable text, optional trim as any) as nullable text

About

Returns the result of removing all trailing characters from the specified text. By default, all the trailing whitespace characters are removed.

  • text: The text from which the trailing characters are to be removed.
  • trim: Overrides the whitespace characters that are trimmed by default. This parameter can either be a single character or a list of single characters. Each trailing trim operation stops when a non-trimmed character is encountered.

Example 1

Remove trailing whitespace from " a b c d ".

Usage

Text.TrimEnd("     a b c d    ")

Output

"     a b c d"

Example 2

Remove trailing zeroes from a text representation of a padded floating point number.

Usage

Text.TrimEnd("03.487700000", "0")

Output

"03.4877"

Example 3

Remove the trailing padding characters from a fixed-width account name.

Usage

let
    Source = #table(type table [Name = text, Account Name= text, Interest = number],
    {
        {"Bob", "US-847263****@", 2.8410},
        {"Leslie", "FR-4648****@**", 3.8392},
        {"Ringo", "DE-2046790@***", 12.6600}
    }),
    #"Trimmed Account" = Table.TransformColumns(Source, {"Account Name", each Text.TrimEnd(_, {"*", "@"})})
in
    #"Trimmed Account"

Output

#table(type table [Name = text, Account Name = text, Interest = number],
    {
        {"Bob", "US-847263", 2.841},
        {"Leslie", "FR-4648", 3.8392},
        {"Ringo", "DE-2046790", 12.66}
    }),