LAMBDA · Dynamic arrays

Running total LAMBDA

xl.running.total spills a running sum. The four utility bills accumulate to $143.60, $239.80, $358.25, and $446.35.

Microsoft 365, Excel 2024, and Excel for the web. Excel 2021 does not have LAMBDA.

Syntax =xl.running.total(values)

xl.running.total
=LAMBDA(values,
  SCAN(0, values, LAMBDA(acc, v, acc + v))
)

Arguments

NameRequiredWhat to pass
valuesRequiredA column of numbers, in the order they should accumulate.

Examples

The four utility bills

=xl.running.total(A1:A4)

Result $143.60, $239.80, $358.25, and $446.35

=SCAN(0,A1:A4,LAMBDA(acc,v,acc+v))B1
Running
AB
1143.60143.60
296.20239.80
3118.45358.25
488.10446.35
A picture of the sheet, not a live calculator. B2:B4 are the spill. The starting 0 is not a row.

xl.running.total is the balance column without a chain of cell references. The utility bills $143.60, $96.20, $118.45, and $88.10 become $143.60, $239.80, $358.25, and $446.35. The last figure is the same $446.35 that SUM returns.

The starting zero is not spilled. The first result is already the first bill.

Add it to the workbook

Copy the formula in the block above, including the line breaks. Choose Formulas, Name Manager, New. Set the name to xl.running.total, the scope to Workbook, and paste into Refers to. Excel Labs can do the same step: open the Advanced Formula Environment, add that name, and save it back to the workbook. A cell then calls =xl.running.total(...).

The name needs Microsoft 365, Excel 2024, or Excel for the web. Excel 2021 returns #NAME? for LAMBDA even when it already has XLOOKUP, FILTER, or LET.

How it works

SCAN starts at 0 and adds each value. Each step is spilled. 143.60 + 96.20 is 239.80. 239.80 + 118.45 is 358.25. 358.25 + 88.10 is 446.35.

Limits

Text and errors stop the scan. A blank is treated as 0 by the addition, so a blank month adds nothing and repeats the previous total. That is different from FILL.DOWN, which copies labels. Do not point both at the same column and expect the same blank behavior.