*ACL* expressions
are combinations of values and operators that perform a calculation
and return a result. Expressions are a valuable and flexible tool.
You can use them to perform a wide range of calculations, to create
filters, to prepare data for analysis, and, as the basis for computed
fields, to create values that do not exist directly in the data.

Expressions can include data fields, functions, literals, constants,
and variables, which can be combined using arithmetic or logical
operators. You can enter expressions manually, or you can build
them using the Expression Builder, which
provides a standard utility throughout *ACL* for creating expressions.

Expressions can be as simple or as complex as needed. A simple
expression could return the result of a basic arithmetic operation
– for example, `Quantity * Cost`. A more complex expression
could reference a number of fields and functions and use operators
to combine the parts of the expression. For example:

`PROPER(first_name) + " " + PROPER(last_name)`

converts all the names in the `first_name` and `last_name` fields
to proper case (initial capital letter followed by lowercase), and
joins the first and last names with a single space between them.

There are four types
of expressions in *ACL*: character, numeric, datetime, and
logical. For example, `Amount + 1` is a numeric
expression because it performs an operation on numbers and returns
a numeric result, whereas `Amount > 1` is a
logical expression because it makes a comparison and returns a logical
result of True or False.

When you create an expression, *ACL* must
be able to evaluate it as one of the following data types:

**Character**– Requires character fields, variables that contain character data, functions that return character values, or quoted character strings (character literals).**Numeric**– Requires numeric fields, variables that contain numeric data, functions that return numeric values, or literal numeric values, without quotation marks, limited to digits, a minus sign if needed, and a decimal point if needed.**Datetime**– Requires datetime fields, variables that contain datetime data, functions that return datetime values, or quoted datetime values (datetime literals). The Datetime data type encompasses three subtypes: date, datetime, and time. Quoted datetime values require backquotes – for example,`‘20141231‘`or`‘20141231.235959‘`. The backquote (`) is the lowercase key at the upper left corner of the keyboard.**Logical**– Requires an operation that produces a logical result of True or False (`T`or`F`), or functions that return logical values. Can reference fields, variables, or literals of any data type. If`T`or`F`are part of the expression, they must be entered without quotation marks.

*ACL* evaluates
expressions from left to right, according to the following rules:

Operators are evaluated in order of arithmetic precedence. Use parentheses ( ) to modify the order in which the expression is evaluated. Each operator works only if its operands are of an acceptable type.

By default, when character strings of different lengths are compared, the shorter of the two lengths is used. If the Exact Character Comparisons option is selected in the Tables tab in the Options dialog box, the longer of the two lengths is used.

If numbers with different precision are mixed in numerical operations, the result retains the decimal places of the operand with the largest number of decimal places in the expression. For example:

4 + 5.0 = 9.0

1.1 * 1.1 = 1.2

6 * 2.000000 = 12.000000

Note

You can use the SET MATH command to change the number of decimal places that result from a mathematical operation.