Text.PadStart
A text made a given length by adding a character in front, such as zeros before a number.
Group: Text and characters. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
Text.PadStart(text as nullable text, count as number, optional character as nullable text) as nullable text
| Parameter | Type | Description |
|---|---|---|
text | nullable text | The text to work on; null gives null. |
count | number | The length the text should reach. |
character | nullable text optional | The character to add, one character. Left out, a space. |
Returns
nullable text. The padded text; a text already that long comes back as it is.
Remarks
- The pad must be exactly one character: a longer text is an error. The count is a whole number from 0.
Examples
An article number with leading zeros
Text.PadStart("42", 6, "0")
"000042"
Spaces in front
Text.PadStart("42", 6)
" 42"
A pad of two characters
Text.PadStart("42", 6, "ab")
Result: an error.
[Reason = "Expression.Error", Message = "The value isn't a single-character string.", Detail = [Value = "ab"]]