Total field?

Answer 'Yes' if you want to total this field's values. The total appears on the subtotal and grand total lines of the report.

Printing a Total Beneath a Column

To print a total beneath the column of figures being totalled, specify the field as:

Total Field ? 'Yes'
List field ? 'Yes'
List on break lines 'Yes'

If you want to add a label to the total value you will have to adopt a different approach.

Labelling aTotal

A frequent requirement is to produce a total with a label. Say you want to produce a simple report which appears like this:

NAME                    ORDER VALUE
Bellerose Capt D P 226.55
727.94

Total Order Value: 954.49

in field processing specify:

  1. CUSTOMER.NAME as a list field, on which you are sorting

  2. ORDER_VALUE as a list field. Total it, but do not list it on break lines, and specify Fold ? 'Yes' to print the next field at the beginning of a new line

  3. LABEL_TOTAL as a calculated field with the formula: "Total Order Value: ". Only list this field on break lines

  4. ORDER_TOTAL as a calculated field with the formula: ORDER_VALUE. Only list this field on break lines

The important point here is that although ORDER_VALUE was totalled in step 2, the total was not printed at that point. The second reference to ORDER_VALUE in step 4, prints the ORDER_VALUE total. Any reference to a totalled field on the subtotal line is a reference to its totalled value. Separating the listed ORDER_VALUE from the totalled ORDER_VALUE allows you to create a label for the total. It also allows you to make use of the totalled value in formulas.

Using Totals in Formulas

The following example extends the previous report to show the use of totals in formulas. To produce a report that looks like this:

NAME                     ORDER VALUE

Bellerose Capt D P 226.55
727.94

Total Order Value: 954.49
Average Order Value: 477.24
Total number of orders 2

in field processing specify fields 1 to 4 as before, plus:

  1. ORDER_COUNT as a calculated field with the formula: 1. The field is totalled to provide a count of the listed records, but not printed

  2. LABEL_AVERAGE as a calculated field with the formula: "Average Order Value: ". Only list this field on break lines

  3. AVERAGE_VALUE as a calculated field with the formula: ORDER_VALUE/ORDER_COUNT. Only list this field on break lines. Fold the field to insert a carriage return before the next field

  4. LABEL_COUNT as a calculated field with the formula: "Total number of orders: ". Only list this field on break lines

  5. COUNT_ORDERS as a calculated field with the formula: ORDER_COUNT. Only list this field on break lines

The important point again is that once a field is totalled you can make use of the totalled value later, either by itself or in formulas, just by referring to the field and specifying list on break lines.

Printing a Running Total

To print a running count at each detail line, for example:

NAME                     ORDER VALUE    RUNNING COUNT

Bellerose Capt D P 226.55 1
727.94 2

Total Order Value: 954.49
Average Order Value: 477.24
Total number of orders: 2

specify a calculated field with the formula: PREVIOUS $ + 1. The field should be listed but not totalled.