List.Accumulate

List

Accumulates a result by applying a function to each item in a list, starting from an initial seed value.

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

Syntax

List.Accumulate(list as list, seed as any, accumulator as function) as any

Parameters

NameTypeRequiredDescription
listlistYesThe list of items to process.
seedanyYesThe initial value to start accumulating from.
accumulatorfunctionYesA function (state, current) => newState that combines each item with the accumulated state.

Return Value

anyThe final accumulated value after processing all items in the list.

Remarks

List.Accumulate is M's "reduce" or "fold" function. It processes each item in a list sequentially, carrying forward a state value that gets updated by the accumulator function. The final state is returned.

This is one of the most powerful list functions — it can implement running totals, string building, multi-step replacements, and any logic that requires carrying state across items.

Examples

Example 1: Sum quantities manually

let
    Quantities = Table.Column(Sales, "Quantity"),
    Total = List.Accumulate(Quantities, 0, (state, current) => state + current)
in
    #table({"TotalQuantity"}, {{Total}})
Result
TotalQuantity
135

Compatibility

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