Why does my index column formula break when sorting the table?
I have a table with approximately 1900 rows in it that has a category column (A) and an index column (G) that uses the following formula (as per this thread and others):
IF(COUNTIF(A$2:A2,A2)=1,MAX(G$1:G1)+1,””)
I fill that formula down the G column and it works correctly no matter how the table is sorted to begin with:
If I then sort the table by another column, my index column breaks. It doesn't matter what column I sort by - if the order of the rows changes, the index column breaks:
I've looked this thing over many times and I have no idea why I can't sort the table - I am not a spreadsheet person but as far as I can see my formula should allow sorting to happen. Right after sorting there is a flash where the index column isn't broken but hasn't updated, then a second or two later the column breaks. Not every row is broken, but most are and I see no rhyme or reason as to why most are broken and a few (1 out of 20?) aren't.
Is it simply that there are too many rows for the app to keep up? It takes a few seconds to calculate that row when I first paste the formula into the column... I'm not doing anything extraordinary and would hope that isn't the case.
Any help would be appreciated! Thank you!