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.
- From the menu select Spread | Restrict/Filter | By Logical Expression.
- In the Columns field, double-click Lwt2 to move it to the Expression field.
- In the Comparisons list, double-click Less Than to add the symbol < to our expression.
- Now type ‘51′ at the end of the expression.
- In the Restriction type section select Include. This tells Genstat to include all rows that match your condition.
- 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.
Expression |
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. |
Logical operators must be delimited by dots (.and. .or. .not.)
Strings must be enclosed in quotes (‘Control’, ‘Once’, ‘Twice’.)
Example
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.
Example
Match all rows where the difference in value between Lwt1 and Lwt2 is greater than 15:
(Lwt2-Lwt1)>15