Tutorial - Page 18
The topics covered in pages 17 and 18 in the Tutorial help topics can also help you print a Grand Total on the last page of your report; just a matter of changing some settings for the variable.
•Add a new Report Band of the type Report Footer (click on BAND, then NEW, then Report Footer)
•Create a new frame inside this new report band; click on the Dictionary button
•Inside the Dictionary dialogue window left click the Grand Totals item; this is located under the Gather Totals section of the User Variables section.
•Click the '+' button to add a new variable
•Assign a UNIQUE name for this new variable; select the database field containing the dollar amount that you want added together. Change the picture length to a longer length than what the selected database field is already set to, and add the '$' character to the string. The "Total Type" will be "sum", and it will be evaluated 'At each record retrieve':
¡ After clicking the save button the dictionary screen is updated:
If you want to put forth the effort, you could define variables for each of the possible states that the database can have (50 states), then modify the Report Footer detail band to print a state by state breakout of sales. To perform this neat trick you would:
Create a variable in the Dictionary for all 50 state abbreviation codes in the Grand Totals section of the dictionary. The variable would make use of 3 internal functions of the Report Builder: Clip(), Upper() and Choose(). The first two functions are used to convert the State database field into a consistent format for testing with the Choose() function. The Choose() function is used to compare the current database record against the known state abbreviation code; if it matches the database field containing the total sales for this customer living in the state is added to the variable (to keep a running total); otherwise it is skipped.
In the Report Footer report band a new frame is added. The Dictionary button is clicked with the empty frame being highlighted. Under the Grand Totals section of the User Variables a new variable is created by clicking the '+' button. For this sample report a new variable is being created for state abbreviation code "FL" (all customers living in Florida). Here is what the variable information looks like:
The Save button is clicked, with inserts the new variable into the frame:
Another trick being used is using the Center attribute for the frame contents for both the text string "Florida" and the Loc:Florida variable. By using the border attributes a table effect is achieved, which makes the summary page look very attractive.
The pattern of adding a new frame for the state abbreviation code, and another frame for a new variable for that state abbreviation code is repeated. You can elect to stack them any way you desire; the choice is yours! Here is how the report band looks at the end:
As shown above, 4 different states are being tracked, with the total dollar sales printed below. Here is the sample output: