My formula won't sum in Crystal Reports

I have a formula that displays only the quantity from a customer's most recent order.  
Part 1:  Find the Max OrderNo for the customer. Using the Running Totals Fields it finds the max OrderNo and evaluates on Change of CustomerNo and resets on Group 2)
Part 2:  If OrderNo = MaxOrderNo then OrderQty else 0. Using Formula Fields with the MaxOrderNo derived from Part 1
Problem:  I need to sum the column of data created by my two part formula, but Crystal is not allowing a cummulative sum on the formula.  I need to sum both the group 2 and the report grand total. Thank you for any help
briankamAsked:
Who is Participating?
 
mlmccCommented:
Maximum is a PrintTime formula and it is evaluated after summary functions are evaluated thus the formula isn't available for a summary.

Modify your formula

WhilePrintingRecords;
Global NumberVar GroupTotal;
Global NumberVar GrandTotal;
Local NumberVar Value;

If OrderNo = MaxOrderNo then
    Value := OrderQty
else
    Value := 0;

GroupTotal := GroupTotal + Value;
GrandTotal := GrandTotal + Value;
Value

In the group header add a formula
WhilePrintingRecords;
Global NumberVar GroupTotal;
GroupTotal := 0;
''

In the main report header
WhilePrintingRecords;
Global NumberVar GroupTotal := 0;
Global NumberVar GrandTotal := 0;
''

To display them
WhilePrintingRecords;
Global NumberVar GroupTotal;
GroupTotal

WhilePrintingRecords;
Global NumberVar GrandTotal ;
GrandTotal

mlmcc
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.