As Keikoku mentioned, you cannot summarize a formula, at least not if there are calculations and assignments.
In addition, you mentioned that you wanted to place this in a group header. That would only look at the first record of each group, as that is the only time that the formula would be invoked.
HTH
If there was no assignment to variables, you could probably summarize it, as all of the values are 'known' when Crystal is making its passes through the data