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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grand Totals

Status
Not open for further replies.

Stella1209

Programmer
Feb 9, 2001
32
US
I am using CR V5 and I have a problem getting Grand totals.The Grand Total field should be placed in Report Footer.
I created Running Total Formulas for Customer, Brunch and Region. For a Grand totals I need to get the SUM of the Region only because Brunch total already includes total for Customers and Region Total includes total for Brunch.It's like a nested Subtotals.
As an example I'll put my Running total Formula for a region:
//goes in group header for Region
WhilePrintingRecords;
if OnFirstRecord = false then
CurrencyVar RunningTotal4:=0
else
RunningTotal4:={C_ILSOBG.DIFF_QTY}

//goes in the detail section

WhilePrintingRecords;
CurrencyVar RunningTotal4;

If {CUS_LOC.NAME} = Previous ({CUS_LOC.NAME}) and {C_ILSOBG.SALES_REP}=Previous ({C_ILSOBG.SALES_REP}) and {SO.SO} = Previous ({SO.SO}) and {C_ILSOBG.SO_LINE}=Previous ({C_ILSOBG.SO_LINE}) and {C_ILSOBG.ITEM}=Previous ({C_ILSOBG.ITEM}) and {C_ILSOBG.DIFF_QTY}= Previous ({C_ILSOBG.DIFF_QTY}) and {C_ILSOBG.TRAN_AMT} = Previous ({C_ILSOBG.TRAN_AMT}) and {C_ILSOBG.DIFF_UNIT_PRICE}=Previous ({C_ILSOBG.DIFF_UNIT_PRICE}) Then
RunningTotal4 :=RunningTotal4
else
RunningTotal4 :=RunningTotal4 + {C_ILSOBG.DIFF_QTY}

//goes in the group footer for Region

WhilePrintingRecords;
CurrencyVar RunningTotal4


Please help me if you have any idea. Thanks in advance.
Stella
 
What happens if you highlight {C_ILSOBG.DIFF_QTY} and select:

INSERT -> GRAND TOTAL

I am not sure why you need to use running totals. Ken Hamady
Crystal Reports Training/Consulting and a
Quick Reference Guide to VB/Crystal (including ADO)
 
Ken thanks for your response.

I need to use running totals because I am suppressing duplicate records and I have to exclude them from totals.

INSERT -> GRAND TOTAL for {C_ILSOBG.DIFF_QTY} will not work because it will add all values (from all groups) of that column. I need to get a SUM only from one group – Region.
I tried to use 3 formulas for Grand total, but the result is wrong and I don't know what I am doing wrong.
T
hese are the formulas for Grand total that I have:

//in Report Header:

WhilePrintingRecords;
if OnFirstRecord = false then
CurrencyVar RunningGrandTotal:=0
else
RunningGrandTotal:={@DispReg}

//in Detail section:

WhilePrintingRecords;
CurrencyVar RunningGrandTotal;
If {CUS_LOC.NAME} = Previous ({CUS_LOC.NAME}) and {C_ILSOBG.SALES_REP}=Previous ({C_ILSOBG.SALES_REP}) and {SO.SO} = Previous ({SO.SO}) and {C_ILSOBG.SO_LINE}=Previous ({C_ILSOBG.SO_LINE}) and {C_ILSOBG.ITEM}=Previous ({C_ILSOBG.ITEM}) and {C_ILSOBG.DIFF_QTY}= Previous ({C_ILSOBG.DIFF_QTY}) and {C_ILSOBG.TRAN_AMT} = Previous ({C_ILSOBG.TRAN_AMT}) and {C_ILSOBG.DIFF_UNIT_PRICE}=Previous ({C_ILSOBG.DIFF_UNIT_PRICE}) Then
RunningGrandTotal :=RunningGrandTotal
else
RunningGrandTotal:=RunningGrandTotal + {@DispReg}

//in Report footer:

WhilePrintingRecords;
CurrencyVar RunningGrandTotal

Please, help me if you can.
Thanks,
Stella
 
Your second formula doesn't account for OnFirstRecord, so you might be missing the first value. It is also easier to eliminate duplicates by accumulating in a group header rather than checking for previous at the details.

What are your group fields, in order that they are used? Ken Hamady
Crystal Reports Training/Consulting and a
Quick Reference Guide to VB/Crystal (including ADO)
 
I did put a condition to check for a first record in a second formula and I am getting the same incorect result.

My Grouped fields are:
Group #1 - Region
Group#2 - Branch
Group#3 - Sales Rep
Group#4 - Customer

All of the groups have running total formulas. So,I cannot make the Sum(grand total) only for a Region Group. Running total for Region already includes totals for Customer, Sales Rep and Branch.



 
The following formula should be placed in the group footer of the region group, and can eventually be suppressed. This causes it to only add one value per region:

WhilePrintingRecords;
CurrencyVar RGT;
RGT := RGT + xxxxx

In place of the xxxxx put the field that PRINTS the final region subtotal for each region. It is probably another running total field.

To display the value use the following formula in the report footer:

WhilePrintingRecords;
CurrencyVar RGT; Ken Hamady
Crystal Reports Training/Consulting and a
Quick Reference Guide to VB/Crystal (including ADO)
 
Ken,
It worked! Thanks a lot! You are GENIUS!!!

Stella
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top