How to get sub and grand total
Dear all, I have a report which combines the two totals together and and makes one formula. This formula then is filtered according to Group2 (Reason Code).
Group 1 is the same Reason Code however with Specified names. Group2 is the same reason code however with ascending order.
My question is how to make the sub total and grand total of this formula.
Detailed Information:

1: Total One  DistinctCount(Order_no),GroupName2  In this Total, the records are counted when Linetype = F
2: Total Two  DistinctCount(Order_no),GroupName2  In this Total, the records are counted when Linetype = S
Formula
Whileprintingrecords; Numbervar x:=0; Numbervar y:=0; Numbervar z:=0; x:={#FOCTC}; y:={#CREDITTC}; z:=x+y; z;
Now this formula is placed in the footer of the Group2 (Reason Code).
What I would like to do is to have a Group2 Sub Total and Finally Grand Total.
I have tried the Following however it doesn't seem to be working.
I created another formula exactly like above and placed it into the same Group footer however removed the "Numbervar o:=0;" (The numbervar z:=0; in the above case however when I created another formula I created named the variable "o" instead of "z") so that it does not reset it.
Then I placed another formula into the Report Footer with the following code
Whileprintingrecords; Numbervar o;
Any ideas?
Many thanks
Regards
Jehanzeb