40% OFF! — Limited Time Offer
← Back to Articles

December 1, 2025

·By El Alaoui Mohamed

Revit IF Statement Tutorial: Complete Guide With Examples

Revit IF Statement Tutorial with real formula examples

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:

Swing_Angle = IF(Swing_Inward, 90°, -90°)

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:

IF(condition, value_if_true, value_if_false)
PartWhat it isExample
conditionEvaluates to true or falseWidth > 900mm
value_if_trueResult when condition is true800mm
value_if_falseResult when condition is false600mm

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:

Swing_Angle = IF(Swing_Inward, 90°, -90°)

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:

Show_Top_Rail = IF(Overall_Height > 2100mm, 1, 0)

Example 3 — Type Switching by Project Phase

A wall finish family labels itself differently depending on the construction phase:

Finish_Label = IF(Is_Existing_Phase, "Paint over existing", "New plaster finish")

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:

Clear_Depth = IF(Nominal_Depth - Frame_Thickness < 150mm, 150mm, Nominal_Depth - Frame_Thickness)

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:

Show_Painted = IF(Finish_Code = 1, 1, 0) Show_Raw = IF(Finish_Code = 1, 0, 1)

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

Frame_Width = IF(Door_Width < 900mm, 75mm, 100mm)

Level 2 — Three outcomes

Frame_Width = IF(Door_Width < 900mm, 75mm, IF(Door_Width < 1200mm, 100mm, 125mm))

Level 3 — Four outcomes

Frame_Width = IF(Door_Width < 900mm, 75mm, IF(Door_Width < 1200mm, 100mm, IF(Door_Width < 1500mm, 125mm, 150mm)))

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.”

❌ Clear_Depth = IF(Nominal_Depth > 300mm, Nominal_Depth - 50, 150mm) ^^ 50 has no unit ✓ Clear_Depth = IF(Nominal_Depth > 300mm, Nominal_Depth - 50mm, 150mm)

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.”

❌ Result = IF(Is_Large, Total_Width, 2) ← length vs. number ✓ Result = IF(Is_Large, Total_Width, 600mm)

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.

❌ Result = IF(A > 0mm, 100mm, IF(A > 200mm, 200mm, 300mm) ^ missing ) ✓ Result = IF(A > 0mm, 100mm, IF(A > 200mm, 200mm, 300mm))

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.