Path: Reporting > Ad Hoc Reporting > Filter Designer > Query Wizard > Filter Parameters
Logical expressions allow you to control how multiple filter criteria work together. Use logical expressions to include or exclude records based on combinations of conditions using AND, OR, and NOT logic. This guide explains how to create and apply a logical expression in the Query Wizard.
Use the Logical Expression field on the Filter Parameters screen to define how multiple filter criteria are combined.
Before you start
- Create a Query Wizard filter.
- Identify the fields you want to use as filtering criteria.
- Assign operators and values to the fields that should be included in the expression. Only fields with assigned operators can be referenced in a logical expression.
Build the logical expression
Use the Logical Expression field to define how the Query Wizard evaluates multiple filter criteria. Logical expressions use the ID numbers assigned to fields in the Filter Parameters editor along with AND, OR, NOT, and parentheses ( ) to control the filtering logic. Only fields with assigned operators can be included in a logical expression.
Use the Logical Expression field to define how multiple filter criteria are combined using AND, OR, and NOT operators.- Review the field IDs assigned to each filter criterion. Logical expressions do not reference field names. Instead, they use the automatically assigned field ID numbers shown in the Filter Parameters editor.
- Enter the expression using the appropriate logical operators. Only fields that have an assigned operator can be included in a logical expression. Fields without an operator cannot be referenced.
- AN: All connected conditions must be true.
- OR: At least one connected condition must be true.
- NOT: Excludes records that meet a specified condition.
- Use parentheses to group conditions and control the order in which the Query Wizard evaluates the expression.
- Parentheses are especially useful when using OR conditions because they allow specific groups of records to be evaluated together before additional criteria are applied. Without parentheses, results may include more or fewer records than intended.
- Review the expression to ensure it matches the population you want to return.
- Test the filter to verify the results.
- If fields are removed from the Filter Parameters editor, the Query Wizard automatically renumbers field IDs and updates the logical expression accordingly.
Impact
The logical expression determines how the Query Wizard evaluates filter criteria and which records are returned. Properly configured expressions allow you to create complex filters that include, exclude, and group records based on multiple conditions. The expression is saved with the filter and is automatically applied each time the filter runs.
Logical expression examples
This example demonstrates how logical expressions reference filter IDs to control the relationship between multiple query conditions.Logical expression: 3 AND 4 AND (5 OR 6) AND 7
Result: Returns students who:
- Are female and
- Have a September birthday and
- Are in grade 9 or grade 12 and
- Are actively enrolled in the selected calendar
The parentheses indicate that a student can satisfy either condition 5 or condition 6 to be included.
Simple AND expression
Expression: 3 AND 6 AND 7
Returns only records that meet all three conditions.
Result: Students who are female, in grade 12, and actively enrolled.
Simple OR expression
Expression: 5 OR 6
Returns records that meet either condition.
Result: Students in grade 9 or grade 12.
AND with grouped OR conditions
Expression: 3 AND (5 OR 6)
A record must meet condition 1 and at least one of the grouped conditions.
Result: Female students in grades 9 or 12.
Tips
- Use parentheses whenever you want multiple conditions to be evaluated together.
- Complex expressions are often easier to understand if you read them from the inside out, starting with any grouped conditions.
- When troubleshooting unexpected results, verify that each condition number in the logical expression matches the intended filter parameter.
What's next
- Configure Output Formatting to determine how results are displayed and exported.
- Configure Grouping and Aggregation to summarize results by group.
- Test the filter to verify the logical expression returns the intended records.
- Save the filter for future reporting and export activities.