I would try modifying the sum macro to include an "IF condition THEN action [ELSE Alternative_Action]", so that when you are stepping through the records if the value of the next macro derived field is greater than the current value, set the new derived field to the greater value.
Just a thought.
David L. Black Consulting