Cumulative count in Numbers surviving sort and categories
Is there a simple method for Cumulative counting that is not broken by data organisation?
In the table below I have some text data in column B and I want to know if that is the first, second third instance of that data in the list.
At first I tried a basic countif from B$4:B5, which when replicated end up B$4:B22 etc. This seems to work but it breaks if the data is sorted. During a sort, If the data row is moved then Numbers mangles this formula.
So I tried using the indirect function to calculate the row value rather than relying on the sort re-writing the formulae. The range to be used in the counter is largely calculated in E3 and modified on a row by row basis. This method survives data sort :-)
BUT it does not survive Categories ... and I do not know why.
This next table is a direct copy of the one above but with categories applied.
Notice that the basic countif function has been re-written by Numbers when categorising. I had no idea that categorisation could lead to code being re-written. Either way, this method still does not survive data sorting.
Of more importance is the error now generated in column E. This formula has not been re-written but the error is suggesting an invalid reference. It seems that the formulae for generating a reference now return (body) in their result (E3 and E4 below).
I have added (but not shown) a function in G3 to remove the bodies using substitute TRIM(SUBSTITUTE(E$2,"(Body)","")) and then used this new G3 formula in the indirect lookup ... this seems to work ... :-)
It just feels to be more complex than it aught to be. Is there a simpler way to do a cumulative count?
My final formula in E2 to calculate the column letter of the data column B became =TRIM(SUBSTITUTE(REFERENCE.NAME(B,0,1),"(Body)",""))
MacBook Pro (M5 Pro, 2026)