Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subtracting TWO Summarized Fields from eachother? Impossible?? 1

Status
Not open for further replies.

PaulinKC

Programmer
Apr 2, 2002
50
US
Senario:

Crystal Reports 8 accessing data from a SQL Server v2000

Report:

Transaction_Type: Total_Amount:

Group(3112)
$800.00
$250.00
Summary Total = $1050.00

Group(3111)
$10000.00
$15000.00
$25000.00

Summary Total = $50000.00

Summary Grand Total = $48950.00

Ok here's my question:

How code a formulae to subtract a summarized total from the grand total when a Transaction_Type of 3112 is being read? Please help!

Thanks,

Paul Friedrichsmeyer
paulf@infini-source.com
 
Just set up a formula in the group footer to capture the sums as they are generated along with an initialize formula in the report header and a display formula...something like

@initialize (report header suppressed)

whilePrintingrecords;
numberVar array totals := [0,0];
numbervar totalcount := 0;


@calc (suppressed in the footer)

whilePrintingrecords;
numberVar array totals ;
numbervar totalcount ;

totalcount := totalcount + 1;
totals[totalcount] := sum(table.amount,groupvalue);

@display

whilePrintingrecords;
numberVar array totals ;

totals[1] - totals[2];


that should do it

Jim



 
Thanks for your help, but for some reason it did not help. The following line:

totals[totalcount] := sum(table.amount,groupvalue);

Kept erroring out and with the message, "A Number Is Required here"
 

totals[totalcount] := sum(table.amount,groupvalue);

Kept erroring out and with the message, "A Number Is Required here"

Did You place this formula in "as-is" or did you substitute the proper values into the sum

table.amount is the field that you are summing
groupvalue is the field that you are grouping on

if the field for table.amount is not a numeric field then we must do a more complicated sum than just this method.


Jim

JimBroadbent@Hotmail.com
 
Jim;

After playing with your solution for a bit, I found that if I did the following:

@type3111

IF {tblARTransaction_Type}=3111 THEN {tblARAmountTotal}

@type3112

IF {tblARTransaction_Type}=3112 THEN {tblARAmountTotal}

Then I summarized both formulas, created a @TotalAmount Formula by subtracting the two previous formulas from eachother. Seemed to have worked like a charm. I do appreciate your help though. You got my brain working again.

Thanks,

Paul Friedrichsmeyer
Infini-Source - One Source Solutions
paulf@infini-source.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top