1. Home
  2. Restrict by Logical Expression

Restrict by Logical Expression

Logical expressions let you restrict the data by defining one or more conditions that must be met. You can choose to include or exclude rows that match the conditions. The expression can be built as a conjunction of two Boolean expressions compounded with an Or or And operator.

For example, we will restrict the spreadsheet below to only display rows where the values in the Lwt2 column are less than 51.

  1. From the menu select Spread | Restrict/Filter | By Logical Expression.


  2. In the Columns field, double-click Lwt2 to move it to the Expression field.
  3. In the Comparisons list, double-click Less Than to add the symbol < to our expression.
  4. Now type ‘51′ at the end of the expression.


  5. In the Restriction type section select Include. This tells Genstat to include all rows that match your condition.
  6. Click Apply to perform the restriction or click OK to perform the restriction and close the dialog.

The resulting spreadsheet now displays only the requested subset of rows.



Input your restriction/filter conditions into one or both fields. You can combine expressions by chaining them together in the first field, or select And or Or and input another expression into the lower field.

For example, the expression below, which has And selected, will select all rows belonging to month 4, 5 or 6 in the year 2017.

Create expression Click this to open the Form Expression dialog, which contains more logical operators to help build your restriction.
Restriction type Select Include to display rows that match your restriction or Exclude to hide these rows.
Existing restrictions If a spreadsheet is already restricted you can Combine the new restriction with the existing one or Replace the existing restriction.
Apply Apply the restriction but leave the dialog open so that you can enter more restrictions using the Combine option.
Remove all Remove all current restrictions on the spreadsheet.

Building logical expressions

Logical operators must be delimited by dots (.and. .or. .not.)
Strings must be enclosed in quotes (‘Control’, ‘Once’, ‘Twice’.)

Match all rows where the column Drench has a value of Once or Twice, and the Lwt2 column has a value greater than 50:
Drench .in. ‘Once’ .or. Drench .in. ‘Twice’ .and. Lwt2>50

You are not restricted to the logical operators in the Comparisons field, but can build your own condition using standard logical functions.

Match all rows where the difference in value between Lwt1 and Lwt2 is greater than 15:

Updated on March 1, 2019

Was this article helpful?