Text.PadEnd

Text

Pads the end of a text value with a character to reach at least the specified total length.

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

Syntax

Text.PadEnd(text as nullable text, count as number, optional character as nullable text) as nullable text

Parameters

NameTypeRequiredDescription
texttextYesThe source text value.
countnumberYesThe minimum total length of the resulting text.
charactertextNoThe single character to use for padding. Defaults to a space character if omitted or null.

Return Value

textThe text value right-padded to at least count total characters.

Remarks

Text.PadEnd adds character to the right (end) of text until the total length reaches at least count. If text is already count characters or longer, it is returned unchanged — no truncation occurs.

If character is omitted or null, a space (" ") is used. The character argument must be exactly one character long; providing a multi-character string raises an error. If text is null, the function returns null.

Right-padding is primarily useful for producing fixed-width output — for example, when writing to positional text files, aligning columns in a report, or normalizing category codes to a consistent length. For left-padding (e.g., zero-padding numeric IDs), use Text.PadStart instead.

Note that Text.PadEnd guarantees a minimum length, not an exact length. If the input is already longer than count, it is returned as-is. If you need to truncate long values as well as pad short ones, combine with Text.Start first: Text.PadEnd(Text.Start(text, count), count, " ").

Examples

Example 1: Right-pad a name to a fixed width with spaces

Text.PadEnd("Alice", 15)
Result
Result
1Alice

Example 2: Pad a category code to a standard length with dashes

Text.PadEnd("Widgets", 12, "-")
Result
Result
1Widgets-----

Example 3: No padding when text already exceeds the minimum length

Text.PadEnd("Engineering", 8)
Result
Result
1Engineering

Example 4: Normalize region codes to a fixed width in a table column

Table.TransformColumns(
    #table({"Region"}, {{"East"}, {"West"}, {"North"}}),
    {{"Region", each Text.PadEnd(_, 8), type text}}
)
Result
Region
1East
2West
3North

Compatibility

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