Text.PadStart

Text

Pads the start 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.PadStart(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 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 1: Zero-pad an employee number to four digits

Text.PadStart("7", 4, "0")
Result
Result
10007

Example 2: Left-pad for right-aligned column output

Text.PadStart("55000", 10)
Result
Result
1 55000

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
    padded
Applied Steps

The final output — zero-pads the numeric portion to four digits with Text.PadStart and prepends the "E" prefix, producing the standardized ID "E0001".

Result
1E0001

Example 4: No padding when text already meets minimum length

Text.PadStart("12345", 3, "0")
Result
Result
112345

Compatibility

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