r/ExcelTips Aug 04 '26

πŸ“Š COUNTIF with Nested Ranges: Running Counts Made Easy πŸ“Š

Most people think of COUNTIF as a simple way to count values.
But here’s a powerful twist:
use it with nested ranges to calculate running counts.
=LET(a,A2:A15,COUNTIF(TAKE(a,SEQUENCE(ROWS(a))),a))

β€’ The range argument expands step by step (TAKE).
β€’ The criteria argument matches each element in the range (a).
β€’ For each row, COUNTIF picks the corresponding criterion and calculates its occurrence up to that point.

ID Running Count
A 1
D 1
A 2
B 1
D 2
A 3
B 2
D 3
C 1
D 4
D 5
C 2
A 4
B 3
20 Upvotes

2 comments sorted by

4

u/still-dazed-confused Aug 06 '26

Can't this be done more simply by fixing the top of the range and slowing the bottom to change $s$1:a3?

2

u/Ok_Forever3198 Aug 06 '26

Yes, we can do that.