Text.Repeat
TextReturns a text value composed of the input text repeated a specified number of times.
Syntax
Text.Repeat(text as nullable text, count as number) as nullable textParameters
| Name | Type | Required | Description |
|---|---|---|---|
text | text | Yes | The text value to repeat. |
count | number | Yes | The number of times to repeat the text. |
Return Value
text — The text value repeated count times.
Remarks
Text.Repeat concatenates text with itself count times and returns the result. If count is 0, an empty string "" is returned. If text is null, the function returns null.
Common practical uses include generating separator strings (Text.Repeat("-", 40) for a horizontal rule), building fill characters for fixed-width output, creating indentation, or constructing test data. When you need to fill a string to a specific total length (rather than repeat a fixed number of times), Text.PadStart or Text.PadEnd are simpler alternatives.
Note that Text.Repeat repeats the exact text including any spaces or special characters. A count of 1 returns the original text unchanged.
Examples
Example 3: Build an indentation prefix for nested output
let
level = 3,
indent = Text.Repeat(" ", level)
in
indent & "- Item"The final output — concatenates the indentation prefix with "- Item" to produce an indented list entry at nesting level 3.
Result | |
|---|---|
| 1 | - Item |