Used to calculate the value of one or more
expressions.

## Syntax

CALCULATE {*expression* <AS *result_label*>} <,...>

## Parameters

`expression`
Specifies the expression to calculate.

- AS
`result_label`
Optional. Specifies the name to associate with the result
when the result is displayed on screen and in the *ACL* command
log. The `result_label` parameter must be a quoted
string or a valid character expression. It is not a variable name.
If this parameter is not specified the expression being calculated
is displayed.

## Remarks

The result of the CALCULATE command
can be a character, logical, numeric, or datetime value. By separating
the expressions to be evaluated with commas, several calculations
can be performed simultaneously.

If you enter the command in the command line, the result
is displayed on screen. If you use the command in a script the result
is recorded in the log. The `result_label` value
is not a variable that you can use in your script. It is only used
to identify the calculation on screen or in the log.

The CALCULATE command provides the functionality of
a calculator combined with access to *ACL* functions, variables,
and the data in the current record. In a numeric calculation, the
result has as many decimal places as the expression component with
the greatest number of decimal places. For example, 365.0000/12.0
is calculated to four decimal places.

If the expression contains
a field value, the table the field belongs to must be open. You
can use the FIND, SEEK, or LOCATE commands to move to the record
to be analyzed by CALCULATE.

## Examples

**a. Performing a simple calculation**

The
following example calculates 4.7 multiplied by 18.5. *ACL* rounds
the result 86.95 to 87.0.

`CALC 4.7 * 18.5 AS "Result"`

**b.
Storing the results of the calculation in a new field**

The
following example calculates the gross margin for the current record
using previously defined fields for the sale price and unit cost.

`CALCULATE
Sale_price - Unit_cost AS "Margin"`