TOTAL command

Calculates the total value of one or more fields in an Analytics table.

Syntax

TOTAL {<FIELDS> numeric_field <...n>|<FIELDS> ALL} <IF test> <WHILE test> <FIRST range|NEXT range>

Parameters

Name Description
FIELDS numeric_field <...n> | FIELDS ALL

The numeric fields to total. Specify ALL to total each of the numeric fields in the table.

IF test

optional

A conditional expression that must be true in order to process each record. The command is executed on only those records that satisfy the condition.

Note

The IF parameter is evaluated against only the records remaining in a table after any scope parameters have been applied (WHILE, FIRST, NEXT).

WHILE test

optional

A conditional expression that must be true in order to process each record. The command is executed until the condition evaluates as false, or the end of the table is reached.

Note

If you use WHILE in conjunction with FIRST or NEXT, record processing stops as soon as one limit is reached.

FIRST range | NEXT range

optional

The number of records to process:

  • FIRST start processing from the first record until the specified number of records is reached
  • NEXT start processing from the currently selected record until the specified number of records is reached

Use range to specify the number of records to process.

If you omit FIRST and NEXT, all records are processed by default.

Analytics output variables

Note

If you total more than one field in a table, the system-generated output variable contains the total for the first listed field only.

Name Contains
TOTALn

The total value calculated by the command.

The value of n is 1 unless the TOTAL command is inside a GROUP command, in which case the value of n corresponds to the line number of the TOTAL command in the GROUP command.

For more information, see GROUP command.

Examples

Totaling the first 25 records

You calculate the total amount of the MKTVAL field for the first 25 records in the table:

TOTAL FIELDS MKTVAL FIRST 25

Remarks

When to use TOTAL

Use TOTAL to verify the completeness and accuracy of the source data and to produce control totals. The command calculates the arithmetic sum of the specified fields or expressions.

ACL Scripting Guide 14.1