yeah, you can't sort/group on a running total as it's value is not known at the time the data is read. I have never tried to sort/group on a formula that is not predicable at the time the data is read, and I don't think that you can.
I believe that you would need to create the count at the time the data is read, so that CR 'knows' the value. A stored procedure is a great way to accomplish this, a Command object might work provided that you can link the count to the file.
HTH