You are here: Commands > Calculate

Calculate

The Calculate command computes and displays the value of an expression.

This command can be issued only in command mode. For more information, see Using Commands.

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

Calculate provides the functionality of a calculator combined with access to Analyzer functions, variables and the data in the current record. In a numeric calculation, the result has as many decimal places as does the expression component with the greatest number of decimal places. For example, the result of 365.0000/12.0 has four decimal places. See Fixed-point Arithmetic for details.

Whenever you use Calculate without providing for the result by using the As modifier, Analyzer names the result with the expression name. See Field Modifiers for more information on the use of “AS”.

Prerequisites

If the expression contains a table field value, the appropriate table must first be opened. Use the Find, Seek or Locate commands to move to the record to be analyzed by Calculate. For more information, see Find, Seek and Search.

Command Mode Syntax

CALCULATE expression <AS "expression-name">

expression allows you to specify any valid Analyzer expression subject to the prerequisites above. See Expression Builder for details on the order of precedence of evaluation of Analyzer expressions and a list of valid operators.
expression name allows you to specify a name for the result of the Calculate command. The name must be surrounded by quotes or be a valid character expression. Default: the expression string.

Examples

To quickly calculate 4.7 multiplied by 18.5 using Analyzer, enter CALC 4.7*18.5 in the Command Log text box.

Click [Accept Entry] or press ENTER to calculate the result. Choose Last Result from the Command Log drop-down list to display the result.

Note: Analyzer rounds the result 86.95 to 87.0.

See Fixed-point Arithmetic for more details.

To calculate the gross margin and gross margin percent for the current record. Using previously defined fields for the sale price and unit cost, calculate the unit gross margin and gross margin percent for the current record. Name the results appropriately and then enter CALCULATE SALEPR-UNCST AS 'MARGIN' in the Command Log text box.

Choose Last Result from the Command Log drop-down list to display the result.