Downloads
Power Query MList: pick and buildBeginner

List.Repeat

Repeats a list a set number of times and joins the copies into one list.

Syntax
List.Repeat(list, count)

Returns: A list made of the original items, repeated.

What it does

List.Repeat makes copies of a list and joins them end to end. The usual finance uses are a placeholder column of the same value, such as a zero for twelve months of an unpopulated budget, or a fixed repeat of a standard row before the real data is added.

Syntax and arguments

Example

A new cost center has no budget yet. The planning model needs twelve months, each set to zero, until the owner sends numbers.

let
    PlaceholderBudget = List.Repeat({0}, 12),
    Total = List.Sum(PlaceholderBudget)
in
    Total

PlaceholderBudget holds twelve zeros, and the total is zero. When real figures arrive, the placeholder is replaced, and the rest of the query does not change.

Example: a second, different use

Repeating a pattern of two items: List.Repeat({"Debit", "Credit"}, 3) returns six items in alternating order, which is handy for building a sample test file.

Things to watch

In business terms

Placeholder budgets, default values for new entities, sample test data and a fixed number of blank periods in a template are typical uses. Make placeholders obvious, so they are not mistaken for actuals.

Related functions

All Power Query M functions · View as Markdown · M basics