Skip to main content

How to group filters in the Query Builder for complex reports.

Explains how the query builder processes the AND, OR and parenthesis functions.

Updated this week

In the One Church Software Query Builder, parentheses are used to group conditions and control the order of logical evaluation, just like in mathematical expressions or advanced search logic. Like in arithmetic, multiplication and division have higher precedence (i.e., are evaluated first) than addition and subtraction.

Similarly, AND has higher precedence than OR and therefore affects the order in which the query is evaluated. And like in arithmetic, parentheses serves as a way to change the order in which an expression is evaluated.

Here’s a breakdown of how they work.

Why Use Parentheses?

• Parentheses help you build complex queries with multiple AND/OR conditions by clearly defining which parts of the logic should be evaluated together.

• Without parentheses, the system evaluates conditions in linear order, which can lead to incorrect or unexpected results.

Example Without Parentheses

Without parentheses, the system may interpret this as:

Is Archived? = no (record type = "Visitor" AND Age < 18)

This would include all Active profiles, OR only Visitors who are under 18, which may not be what you intended.

Example With Parentheses

This means: Only include people who are either Active profiles OR profiles who are Visitors, but only if they are under 18.

How to Add Parentheses in One Church Software

1. While building your query, you’ll see an option to "Add parenthesis"

2. After adding this, select the filter, then click in the highlighted area.

Tips for Using Parentheses

• Always preview results to ensure your logic works as expected.

• Try sketching your logic out before building it in the Query Builder.

•Use “AND” within groups for tighter matching, and “OR” to expand the results.

Did this answer your question?