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.
Syntax =xl.running.total(values)
=LAMBDA(values,
SCAN(0, values, LAMBDA(acc, v, acc + v))
)Arguments
| Name | Required | What to pass |
|---|---|---|
| values | Required | A 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
| A | B | |
|---|---|---|
| 1 | 143.60 | 143.60 |
| 2 | 96.20 | 239.80 |
| 3 | 118.45 | 358.25 |
| 4 | 88.10 | 446.35 |
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.