Link to home
Create AccountLog in
Avatar of cozmo_troll
cozmo_troll

asked on

Sum in Report Footer; sum formula field

I have a report that includes data and shared variables from several subreports. I have all of the individual formulas working correctly, but I need to do some total fields in the report footer now. When I try to do this it either tells me that I must enter a field here or that this field can not be summed. Ideas please?
Avatar of analliah
analliah
Flag of United States of America image

I'm assuming that you are trying to sum the fields from the subreports and the main report into your report footer.
Avatar of cozmo_troll
cozmo_troll

ASKER

Sort of; there are calculated fields using the fields from the subreports that I am trying to sum in the footer.
Avatar of Mike McCracken
Since the formulas use SHARED variables they are calculated in the PRINTING RECORDS pass.  Yhe summary functions are done in an earlier pass so they can't be used.

You will need to do the summary through formulas and variables

Add a formula to the report header to declare a global variable for the total.

WhilePRintingRecords;
Global NumberVar MyTotal := 0;

Where you have the value to be totaled
WhilePRintingRecords;
Global NumberVar MyTotal;
Shared NumberVar MyShared;

MyTotal := MyTotal + MyShared;

In the report footer
WhilePRintingRecords;
Global NumberVar MyTotal;
 MyTotal

mlmcc
mlmcc,

Ok, I have the first and last part and they both show zero. However, I do not understand how to do the middle part. I'm not just needing to sum an individual Shared Var; the shared Vars are used along with other data to create totals in the data of the report; I need to sum those totals, not the individual var?
mlmcc,
 does this take care of all the different formula that you are adding from the different subreport.
Can you post the report to this site or one of the formulas you need totaled?

mlmcc
This is the formula I needed totaled: {@ASP}*{@TotalQtyOnCustomerOrders}

>>@ASP's formula is: if ({@TotalQtyOnCustomerOrders}>0) then formula =(({@TotalPriceOrders}+{@TotalPriceInvoices})/{@TotalQtyOnCustomerOrders})

>>@TotalQtyOnCustomerOrders formula is:formula={@QtyOnOrder2}+{@QtyOnOrderTotal}

>>@QtyOnOrder2's formula is:WhilePrintingRecords;shared numberVar TotalQtyOnOrders

>>@QtyOnOrderTotal's formula is:WhilePrintingRecords; shared numberVar TotalQtyOnInvoices

Thank you!
In the formula {@ASP}*{@TotalQtyOnCustomerOrders}
Crystal synax
Global NumberVar MYTotal;
Local NumberVar CurrentValue;
CurrentValue := {@ASP}*{@TotalQtyOnCustomerOrders};

MyTotal := MyTotal + CurrenValue;
CurrentValue

mlmcc
mlmcc,

I'm sorry if I am stupid and don't understand something. But, when I copy what you have above into the formula called: Gross (the original formula name that contains  {@ASP}*{@TotalQtyOnCustomerOrders}) it comes up with "The remaining text does not appear to be part of the formula.

This is what the entire formula looks like, and it is in Crystal syntax:
{@ASP}*{@TotalQtyOnCustomerOrders}
Global NumberVar MYTotal;
Local NumberVar CurrentValue;
CurrentValue := {@ASP}*{@TotalQtyOnCustomerOrders};

MyTotal := MyTotal + CurrenValue;
CurrentValue
Never mind. I figured it out by elimnating the top line and also correcting the typo in the 2nd to last line. Thank you.
mlmcc,
could you advise one other thing quickly? I have a similar field that needs an average?
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account