Power QueryExercises

Text.PadStart

Text function · By Tahir Nas · Examples run in our simulator · Published · Updated

Pads text on the left to a given length.

When to use it

Use it to restore leading zeros on codes, account numbers or ZIP codes that were read as numbers, so they match the other system's format.

Syntax

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

Parameters

character
Pad character (default space).

Returns

The padded text.

Example

Text.PadStart("104", 6, "0")

Result

000104

Example: rebuild a code from a number

Convert the number to text, then pad to the fixed width.

Text.PadStart(Text.From(42), 5, "0")

Result

00042

Both results are produced by the Power Query Exercises simulator, an independent implementation of a documented subset of M, and checked on every build.

Good to know

Common mistakes

Exercises that use Text.PadStart

Learn more

Related functions

Official documentation: Text.PadStart on Microsoft Learn.