How to get a running count of occurrences
✓ Verified in LibreOffice 25.8.7.3Number each appearance of a value as it recurs down a column — 1st, 2nd, 3rd time seen.
The formula
| App | Formula | Notes |
|---|---|---|
| Excel | =COUNTIF($A$2:A2,A2) | Put it beside the first row and fill down — the expanding range does the work. |
| Google Sheets | =COUNTIF($A$2:A2,A2) | Identical. |
| LibreOffice Calc | =COUNTIF($A$2:A2,A2) | Identical. |
How it works
The trick is the half-anchored range $A$2:A2: the start is locked but the end grows as you fill down, so each row counts occurrences of its own value from the top down to itself. By row 4, "apple" has appeared twice, so its running count is 2. Useful for numbering duplicates, making unique keys (=A2&"-"&COUNTIF($A$2:A2,A2)), or finding each value's first appearance (running count = 1).
Verified, not just documented
We ran =COUNTIF($A$2:A4,A4) in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned 2 — exactly the expected result. Every formula here is confirmed by actually executing it.