Text.PadStart
TextPads the start of a text value with a character to reach at least the specified total length.
Syntax
Text.PadStart(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 left-padded to at least count total characters.
Remarks
Text.PadStart adds character to the left (start) 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.
The most common use of Text.PadStart is zero-padding: converting numeric text like "7" to a fixed-length string like "007". This is essential when generating codes, invoice numbers, or IDs that must sort correctly as text. To format a number directly without converting to text first, use Number.ToText with a custom format string (e.g., Number.ToText(7, "000")).
Like Text.PadEnd, this function guarantees a minimum length, not an exact length. Inputs that are already longer than count are returned as-is. For right-padding, use Text.PadEnd.
Examples
Example 3: Standardize employee IDs to four-digit format
let
id = "E001",
numPart = Text.End(id, Text.Length(id) - 1),
padded = "E" & Text.PadStart(numPart, 4, "0")
in
paddedThe final output — zero-pads the numeric portion to four digits with Text.PadStart and prepends the "E" prefix, producing the standardized ID "E0001".
Result | |
|---|---|
| 1 | E0001 |
Example 4: No padding when text already meets minimum length
Text.PadStart("12345", 3, "0")Result | |
|---|---|
| 1 | 12345 |