Text.Repeat

Text

Returns a text value composed of the input text repeated a specified number of times.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Text.Repeat(text as nullable text, count as number) as nullable text

Parameters

NameTypeRequiredDescription
texttextYesThe text value to repeat.
countnumberYesThe number of times to repeat the text.

Return Value

textThe 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 1: Create a separator line

Text.Repeat("-", 30)
Result
Result
1------------------------------

Example 2: Repeat a multi-character pattern

Text.Repeat("= ", 5)
Result
Result
1= = = = =

Example 3: Build an indentation prefix for nested output

let
    level = 3,
    indent = Text.Repeat("  ", level)
in
    indent & "- Item"
Applied Steps

The final output — concatenates the indentation prefix with "- Item" to produce an indented list entry at nesting level 3.

Result
1 - Item

Example 4: Zero repetitions returns an empty string

Text.Repeat("Widget", 0)
Result
Result
1null

Compatibility

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