Text.PadEnd
TextPads the end of a text value with a character to reach at least the specified total length.
Syntax
Text.PadEnd(text as nullable text, count as number, optional character as nullable text) as nullable textParameters
| Name | Type | Required | Description |
|---|---|---|---|
text | text | Yes | The source text value. |
count | number | Yes | The minimum total length of the resulting text. |
character | text | No | The single character to use for padding. Defaults to a space character if omitted or null. |
Return Value
text — The 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 2: Pad a category code to a standard length with dashes
Text.PadEnd("Widgets", 12, "-")Result | |
|---|---|
| 1 | Widgets----- |
Example 3: No padding when text already exceeds the minimum length
Text.PadEnd("Engineering", 8)Result | |
|---|---|
| 1 | Engineering |
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}}
)Region | |
|---|---|
| 1 | East |
| 2 | West |
| 3 | North |