Counting unique values in a single column - and make it still work after sorting
Hello, I have a column for names, a column (using a checkbox) for "no longer participating", and a column for a school. I want to count the sum of unique school in the column. I am using the formula I found on an older support page:
=IF(COUNTIF(A$1:A1, A2)=0,1,"")
It works. It's important to note that the name column is sorted with the names of participating students in ascending order, and then in the same column, the non-participating students are listed in ascending order. (Some school cells are blank for both participating and non-participating students). See screenshot:
If I need to change the sorted order to ALL students, participating and non-participating (in ascending or descending order), the formula breaks - specifically where the non-participating students get moved up and sorted among all students - the "A$1" loses its reference. How do I protect against this? Someone once showed me, and I think it involved using a hidden column that numbers each row so that even if the name changes position, the row number is always constant - but I don't remember the full solution. Thanks in advance.
iMac (2017 – 2020)