You are here: Analyzer Concepts > Additional Operations and Routines > Expressions

Expressions

Expressions let you ask questions about your data. They are used primarily to create filters and computed fields. Expressions perform calculations, specify logical conditions for a test or create values that do not exist in the data file. For example, a data file may have fields for quantity and unit cost. You could create a new computed field for analysis that contains the value quantity multiplied by unit cost.

An Analyzer expression can be a combination of data fields, functions, constants, variables, and operators. You can use expressions to create ad hoc or permanent computed fields, and to perform include/exclude operations using filters. Expressions range from the very simple, such as:

Quantity * Cost

to the complex, such as:

SUBSTRING(UPPER(Name),1,3) + STRING (Salary,5)

There are four kinds of expressions:

Numeric
Character
Logical
Date

Computed Fields

A computed field is a special type of expression. Computed fields do not contain physical data. They are virtual fields that use data derived from a calculation. Computed fields let you perform calculations based on information in a data file without altering the original data.

Filters

Filters are logical expressions or fields that return a true or false result. For example, AMOUNT>100 can be answered true or false, but AMOUNT+100 cannot. Filters compare the values in a field with a constant or with values in another field.

Filters let you select the kind of data you want to see and use. For example you can use filters to limit the data that you read from the source file or to limit the data displayed in the View. Filters can also be used as tests or conditions that must be met for a process to start, continue or stop.

You can apply successive filters at almost every stage of your analysis to precisely identify the data you need. You can also create compound filters, with the result from one test leading to another test, and so on.

If Statement

An If statement is a logical condition that controls whether a command is executed. Analyzer executes a command only when the specified condition is true. For example, to extract all records dated later than March 31, 2000, you would use the Extract command with the following If parameter: DATE > `20000331`. Analyzer will process the entire file, processing every record that meets the condition.

While Statement

A While statement is a logical condition that applies to a command after it begins processing. It limits the processing to records that meet a logical test and terminates processing as soon as the test fails.

For example, to limit the operation of the Extract command to records with a negative value in the amount field, you would ensure the file is ordered with the amount field in ascending order. This will place the lowest value records at the beginning of the file. Then you would use the While statement AMOUNT < 0. Analyzer will process the file until it finds a record for which this condition is not true.