UX Pickle

UX for Composing Boolean Logic

Reading Time - 3 min

Boolean Logic UIs are difficult to interpret.

The main problem non-technical users have with Boolean logic is understanding the difference between AND and OR because it doesn’t always correspond to natural language (e.g., “show me orders from New York and New Jersey” almost certainly means Location = NY OR Location = NJ). Often users tend to interpret “or” to be an exclusive OR. Then there’s the issue of losing track of nested parentheses.

If you’re planning to use Boolean logic in your UI, you should test it to ensure that it’s understandable. Here are some common errors users make that you as the UX designer should watch out for:

  1. Confusing AND and OR (e.g., OR instead of AND).
  2. Using a single OR rather than a double OR (e.g., OR instead of || ).
  3. Forgetting parentheses in nested logic (e.g., (NY OR NJ) OR (CA OR TX) instead of (NY || NJ) || (CA || TX) ).
  4. Neglecting the use of parentheses in complicated logic (e.g., (NY OR NJ) OR (CA OR TX) instead of ((NY OR NJ) OR (CA OR TX)) ).
  5. Using double OR instead of double AND (e.g., || instead of && ).
  6. Interpreting “or” as an exclusive OR (e.g., OR instead of OR ).
  7. Forgetting that “AND” and “OR” can take two or more arguments (e.g., (New York AND New Jersey) instead of (New York AND New Jersey) AND (California AND Texas)).

Query Builders

Query builders are one of the few places where it makes sense to have separate Basic and Advanced modes. You’ll probably find that 90% of your users’ queries fit only a few patterns. It makes sense to have these as canned or semi-canned queries that can be selected and specified easily while putting something like Kaleidoquery under Advanced for the rarer ad hoc querying.

In many cases, the advanced modes are just a user interface for query parameters, which you can get to through the Advanced menu of a query builder. In others, they provide a new way for a power user to get to a query. In some cases, they provide a way for a power user to get to a query that’s too complex for a user interface. If you decide to use query builders for advanced users, be sure to document how to use them.

Remember that query builders are one of the places where it makes sense to use an Advanced mode. If your power users have to hunt around for query parameters, the query builder will just become another tool that’s too hard to use.

Research on Kaleidoquery suggests some best practices for building boolean logic composers.

Examples of Good Boolean Logic UX

We have compiled a list of UI that users prefer.


Apple has a number of interfaces that they released to solve this problem:

alt text

Microsoft Access

Microsoft Access made a reasonable attempt at a simple database query UI by producing a visual version of “Query by Example”.


Drag and Drop Interface

This interface is well-tested with both technical and non-technical users:

db query builder

Wizard or Stepper

The decision of choosing one interface over another also depends on the type of users you are dealing with. For non-technical users, a wizard with multiple steps might work better.

enter image description here

Instead of having it on multiple screens, you can also choose to reveal steps progressively:

Interface for composing boolean logic

We hope these examples gave you the inspiration to sketch your own Boolean logic interface. Let us know how you implemented yours in the comment section below.

Leave a Reply