Running total column based on value in previous row


I’m trying to keep a running total (headcount) in my example:

As you can see, the result for every row, except the first, seems to be some sort of cell identifier (as text) with the movement value added (again as text).

I’ve seen adding-values-from-previous-rows but the formula format using square brackets doesn’t seem to work.

Is it possible to write a formula that takes a value from the previous row?

Additionally, it seems that when using nth you only get back the ‘display value’, which in my example is OK, but it would be really nice if there was a way to refer to a specific column.


Hi @Nick_Holt,

Here is what I came up with:

initialHeadcount + Headcount.Filter(CurrentValue.[Row ID] <= thisRow.[Row ID]).Movement.Sum()

This does, however, assume that your list has been created in order. If you add a row in the middle, the formula no longer works.

I’m working on a formula that doesn’t care about added order. I’ll let you know if I come up with something.

PS - The “Row ID” column appears to need to exist for this formula to exist. Just create it using the “Row Properties” -> “Row ID” column type, and then hide it. Apparently, you cannot get the RowID of CurrentValue.



@Nick_Holt @Lloyd_Montgomery

This seems to work, despite the “Wrong argument type” message in the [visual row position] column formula.


Hi @Ander,

(Excuse the edit… In looked too quickly)

That is brilliant! I couldn’t figure out how to find the index of the row we were on, and you did it… Well done.

Here is my alternative solution with the formula from Ander integrated:

Note: I imagine the solution from Ander is in fact better on performance, since mine calculates a sum across all previous rows, for every row. (But mine doesn’t have an “If”) Ander just calculates based on the last row. Without knowing more about Coda’s implementation, I can’t say more.




I edited that post twice, so just to clarify: [visual row position] is a formula, not manually populated.


@Ander Yeah I edited mine as well after I realized I reacted too quickly. Brilliant solution. I will definitely be using this in my future formulas.




Credit to @Krunal_Sheth. I got the idea from his post here: Visual Position of the row in table