The reason you cannot use either the built in Summary or the built in Running Total field stems from your original formula.
You are using the function Previous in the formula @actualHeadway. That function, which is a very useful function, is from the Print State category of functions and any formula that uses any functions in this category calculate WhilePrintingRecords. (The IsNull function is an exception and doesn't really belong in this category).
Formulas calculate at one of three different times:
BeforeReadingRecordse.g. currentdate - 1
These formulas calculate once per report
WhileReadingRecordse.g. {Table.Field} * {Table.Field2}
These formulas calculate once per record
WhilePrintingRecordse.g. Previous({Table.Feild})
These formulas calculate based on which section you place them in
Only formulas that calculate WhileReadingRecords can be summarized using the built in Summary or can have a Running Total used on them.
And any formula that calculate WhilePrintingRecords cannot be summarized since Crystal executes the built in Summary and Running Total before it processes the WhilePrintingRecords formulas.
So if you have a WhilePrintingRecords formula and you want to summarize it you have to do the sum yourself using variables.
A set of three formulas is normally used. One to accumulate the value (placed in the detail or group). One to Reset (Placed often in the Group Header) and one to Display. The Reset formula can be skipped if you are not resetting the variable when the group changes.
Below are an example of the formulas that might give you an idea on how to do your own total.
//Formula 1 - Accumulate Formula - placed in the detail section (or sometimes in the lower level group)
WhilePrintingRecords;
numberVar EarlyCount;
numberVar LateCount;
numberVAr OnTimeCount;
EarlyCount := EarlyCount + if {@HeadwayStatus} = "Early" then 1 else 0;
LateCount := LateCount + if {@HeadwayStatus} = "Late" then 1 else 0;
OnTimeCount := OnTimeCount + if {@HeadwayStatus} = "OnTime" then 1 else 0;
//Formula 2 - Reset Formula - this is normally placed in the Group Header but can be skipped if the variables do not need to be reset
WhilePrintingRecords;
numberVar EarlyCount := 0;
numberVar LateCount := 0;
numberVar OnTimeCount := 0;
//Formula 3 - Display Formula - This is placed normally in the Group footer or Report Footer
WhilePrintingRecords;
numberVar EarlyCount; //Comment out the line you don't want
numberVar LateCount; //Comment out the line you don't want
numberVar OnTimeCount; //Comment out the line you don't want
Another alternative to this set of three print time formulas is to redo your original formula without using the Previous function so it calculates WhileReadingRecords. That can sometimes be a better solution.
Gordon BOCP
Crystalize