Summary in Crystal report
-
09-10-2019 - |
Question
In Segate Crystal Report how to add the summary ie. @ last page I need total number of pages and number of records in respective page and total Balance Amount of that respective page.Please help me out to solve this problem.
Example:-
Pages No of accounts TotalBalance.
Page 1 38 42000.00
page 2 40(Excluding page 1 Records) 12000.00(Exclud page1 Records)
Page 3 30(Excluding page1,2 Records) 10000.00(Exclud page1,2 Records)
:
:
:
So on
Thanks,
Karthik
Solution
Here's an attempt at trying to do this with Formula Fields...
Step 1 - Create Formula Field to reset the total on each new page.
Create a new Formula Field to reset the page totals add this to the Page Header section. Call the field ResetOnNewPage and add the following formula (in Crystal Syntax)
WhilePrintingRecords;
Global NumberVar PageTotal := 0;
Global NumberVar RowCount := 0;
Add this to the Page Header section and hide it by ticking Suppress in the Format Editor
Step 2 - Create a Formula Field to perform the running total.
Create a new Formula Field called CalculateOnEachDetail and add the following formula
WhilePrintingRecords;
Global NumberVar PageTotal;
Global NumberVar RowCount;
PageTotal := PageTotal + {Command.s};
RowCount := RowCount + 1;
Note: You'll need to change the bit in the curly braces to reflect your table/Fieldname. (I used a command with a single field called 's')
Add this to the Detail section and again hide it in the Format Editor
Step 3 - Create a Formula Field for each of the two values we are calculating
Create one formula field called ShowPageTotal with the following formula
WhilePrintingRecords;
Global NumberVar PageTotal;
PageTotal;
And one formula field called ShowRowCount with the this formula
WhilePrintingRecords;
Global NumberVar RowCount;
RowCount;
Drop this on the page footer and Bob's your uncle!
OTHER TIPS
Crystal Reports doesn't "think" in terms of pages. It thinks in terms of records and groups. As such, there is no function that says "For all records on this page, add this number". There are ways around this limitation, but they'll take some time for you to understand & develop.
The first method I can think of is to structure your report so that the same number of records appear on each page. For example, if exactly 10 records appeared on each page, then you can make a running total to add 10 records at a time and then reset.
The second method would involve getting creative with making a custom grouping variable and only showing 1 group per page.