# Using Logical Operators in Expressions

An expression is a formula that returns a value. In Monarch Classic, expressions are used to define filters and calculated fields and to perform field-based searches in the Table window.

When creating expressions in Monarch Classic you can use logical operators. A logical operator is used to combine comparisons. Monarch Classic allows the use of the .And., .Or., .Not., .In.(), and .NotIn.() logical operators in expressions.

Each of the logical operators is described below:

### Options

 Logical Operator Description .And. Requires both halves of an expression to be TRUE. For example, the following expression evaluates to TRUE only for records where both the Lastname is "Lambert" and the City is "Chelmsford": Lastname="Lambert".And.City="Chelmsford" .Or. Requires either half of an expression to be TRUE. For example, the following expression evaluates to TRUE for all records where either the Lastname is "Lambert" or the City is "Chelmsford": Lastname="Lambert".Or.City="Chelmsford" .Not. Requires an expression to be FALSE. For example, the following expression evaluates to TRUE for all records where the City is NOT "Boston" .Not.City="Boston" Note that the above expression is equivalent to City<>"Boston" .In.() Determines whether a value is present within a list of values. Syntax: value .In.(value1, value2, etc) value is typically a field name that includes the values you want to evaluate against a list of values. value may also be the result of a function or of an expression. value1, value2, etc, represents a list of values to evaluate against. All values in the list must be of the same type (character, number, or date) as the value to the left of the .In. operator. The .In. operator returns zero (boolean FALSE) if the value is not found among the listed values, or 1 (boolean TRUE) if the value was found. For example, the expression Media .In.("CD","LP","DVD") is equivalent to the expression Media="CD".or.Media="LP".or.Media="DVD" Both expressions evaluate to 0 (boolean FALSE) if the Media value does not match one of the designated string values. Otherwise, both expressions evaluate to 1 (boolean TRUE) indicating that the value matches one of the designated string values. .NotIn.() Determines whether a value is not present within a list of values. Syntax: value .NotIn.(value1, value2, etc) value is typically a field name that includes the values you want to evaluate against a list of values. value may also be the result of a function or of an expression. value1, value2, etc represents a list of values to evaluate against. All values in the list must be of the same type (character, number, or date) as the value to the left of the .NotIn. operator. The .NotIn. operator returns 1 (boolean TRUE) if the value is not found among the listed values or 0 (boolean FALSE) if the value is found. For example, the expression Media .NotIn.("CD","LP","DVD") is equivalent to Media<>"CD".and.Media<>"LP".and.Media<>"DVD" Both expressions evaluate to 1 (boolean TRUE) if the Media value does not match one of the designated string values. Otherwise, both expressions evaluate to 0 (boolean FALSE) indicating that the value matches one of the designated string values.