The control group on which a sum is reset must be at either the same level as or a lower level than the sum.
Resolution:
Refer to the chapter Report Writer in the Language Reference - Additional Topics for the rules governing the resetting of sums. Revise your code accordingly.