TL;DR
The Revit IF statement returns one of two values based on a condition: IF(condition, value_if_true, value_if_false). Both branches must return the same parameter type. Nesting beyond 3 levels becomes unmaintainable — use a lookup table instead. The three most common errors are inconsistent units, inconsistent types, and unbalanced parentheses.
Key Takeaways
- ✓IF syntax has exactly 3 parts: condition, value_if_true, value_if_false — separated by commas.
- ✓Both branches must return the same parameter type — mixing lengths with numbers causes an error.
- ✓Yes/No parameters can drive visibility, angles, text labels, and dimension guards.
- ✓Nested IFs beyond 3 levels are hard to maintain — switch to a CSV lookup table.
- ✓Material assignment via IF is not directly possible — use the visibility toggle workaround.
- ✓The 3 most common errors: inconsistent units, inconsistent types, unbalanced parentheses.
You have a door family. The hardware supplier specifies a 90° swing for inward-opening doors and a −90° swing for outward-opening doors. Instead of maintaining two separate families or manually overriding the angle every time, you write one formula:
Toggle the Swing_Inward Yes/No parameter — the angle updates instantly. That is what the Revit IF statement does: it replaces a manual decision with a formula-driven one.
Basic IF Statement Syntax
Every Revit IF statement has exactly three parts:
| Part | What it is | Example |
|---|---|---|
| condition | Evaluates to true or false | Width > 900mm |
| value_if_true | Result when condition is true | 800mm |
| value_if_false | Result when condition is false | 600mm |
Rules: the condition must evaluate to Yes/No. Both value branches must return the same parameter type. All three parts are separated by commas inside one pair of parentheses.
5 Real-World IF Formula Examples
Example 1 — Door Swing Direction
A door family flips the swing angle based on whether it opens inward or outward.Swing_Inward is a Yes/No parameter:
Example 2 — Component Visibility by Height
A furniture family shows a decorative top rail only when height exceeds 2,100 mm. Assign Show_Top_Rail (Yes/No) to the geometry's Visibility property:
Example 3 — Type Switching by Project Phase
A wall finish family labels itself differently depending on the construction phase:
Example 4 — Dimension Control With a Minimum
A shelf family calculates depth from the wall face but must never fall below 150 mm. Without this guard, negative dimensions crash the family:
Example 5 — Conditional Material Assignment (Workaround)
Revit does not support direct material assignment via IF. The workaround uses two geometry instances — one per material — with visibility toggled by Yes/No parameters:
Finish_Code is an integer parameter (1 = painted, 0 = raw). The two geometry instances toggle in and out of visibility based on its value.
Nested IF Statements
When you need more than two outcomes, replace value_if_false with another IF:
Level 1 — Two outcomes
Level 2 — Three outcomes
Level 3 — Four outcomes
Three levels is the practical limit. Beyond that — adding a new size means rewriting the entire formula, debugging is extremely difficult, and no one else can maintain it. When you reach Level 3 with more conditions ahead, switch to a Revit lookup table. A CSV file handles any number of conditions with no nesting at all.
3 Common IF Errors and How to Fix Them
Error 1 — Inconsistent Units
Message: “The formula contains an inconsistent unit.”
Prevention: Every numeric constant in a length formula must include a unit. Scan each constant before saving.
Error 2 — Inconsistent Data Types
Message: “The formula is inconsistent.”
Prevention: Before writing the IF, decide the output type. Both branches must match.
Error 3 — Unbalanced Parentheses
Message: “Invalid formula” or the bar turns red immediately.
Prevention: Count opening and closing parentheses — they must be equal. For a systematic approach to all formula errors, see why Revit family formulas stop working.
When to Use Lookup Tables Instead
Use an IF statement for two or three outcomes with simple logic. Switch to a Revit lookup table when you have more than three size variations, the values come from a spec sheet, or the nested IF is already at Level 3.
Go deeper
All 10 formula types — one complete guide
IF statements, lookup tables, trigonometry, Yes/No automation, and more. Ebook + HD Video Vault + Cheat Sheet. 40% off at $18.
