How to combine boolean expressions in PropertyWizard for Revit

This post explains how to combine boolean (Yes/No or True/False) expressions in your PropertyWizard formulas. I’ve written about finding text and using boolean expressions before, but never explained how to combine more than one boolean together. This post fixes that omission.

There are two different ways to combine booleans in PropertyWizard: Logical Functions and Logical Operators. They both do exactly the same thing, so you can use whichever you find easier.

Logical Functions

These are the and() and or() functions. You can give them any number of boolean expressions, and they will return the logical result.

  • and() returns true if all the input expressions are true
  • or() returns true if any of the input expressions are true.

So if you want the formula to find all the Rooms on Level 1 that are between 5 and 10 square metres in area, you could use an and() like this:

and(Level.Name == "Level 1", Area >= 5 sqm, Area <= 10 sqm)

If you want to find all the Rooms called “Bedroom”, “Main Bedroom” or “Second Bedroom”, you could use an or() like this:

or(Name == "Bedroom", Name == "Main Bedroom", Name == "Second Bedroom")

You can see how each of the inputs is a complete logical expression:

 Name == "Bedroom"

That’s important, because it isn’t possible to do things like this:

These will not work:
or(Name == "Bedroom", "Main Bedroom", "Second Bedroom") >>> ERROR
Name == or("Bedroom", "Main Bedroom", "Second Bedroom") >>> ERROR

Logical Operators

These are the And operator && and the Or operator ||.

You can use them in to do exactly the same calculations as the logical functions. The only difference is the way they are laid out: You have to put the operator between each input expression:

Level.Name == "Level 1" && Area >= 5 sqm && Area <= 10 sqm 

So if you have lots of expressions to combine, it can be easier to use the functions rather than the operators. But if you’re just combining two expressions, the operators are probably easier to use:

Name == "Main Bedroom" || Name == "Second Bedroom"

In Revit

Here are the four formulas in Revit, and a Room Schedule showing them operating on a selection of Rooms:

PropertyWizard Formulas window showing the four formulas described in the article
Revit Room Schedule showing the results of the four formulas described in the article

If you’d like to try these formulas for yourself, you can download a zip of the xml formula file and Import them into your project in PropertyWizard.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.