In a Revit family, an IF formula tests a condition and returns one value when it is true and another when it is false. For example, with a length parameter named Width, the formula if(Width > 3' 0", "Wide", "Narrow") returns “Wide” when Width exceeds 3 feet and “Narrow” otherwise; unlike an Excel formula, a Revit family formula does not begin with an equals sign.
What an IF formula does in Revit
Revit family formulas let a parameter respond to other parameter values. An IF formula is useful when a design needs a simple either-or decision: select one label, dimension, number, or yes/no result according to a condition. Changing the input parameter then recalculates the formula result, helping a family adapt to different sizes or configurations.
The basic pattern is if(condition, value_if_true, value_if_false). The condition is a comparison, such as Width being greater than a threshold. The two results must be compatible with the parameter that contains the formula. For example, a text parameter can return text, while a length parameter should return lengths. Revit evaluates the condition and returns only the matching result.
These examples concern formulas in Revit family parameters, commonly edited in the Family Types dialog. Revit also has calculated values in schedules; those are configured in a schedule and are not the same place or workflow as a family parameter formula.
Basic syntax and comparison operators
Revit’s family formula syntax uses the function name if followed by three comma-separated arguments. Use ordinary comparison operators to build the condition: = for equal to, != for not equal to, > for greater than, < for less than, >= for greater than or equal to, and <= for less than or equal to. Use the exact parameter name shown in the family.
In formulas, text results go in straight double quotation marks, as in "Type A". Boolean results use true and false. Include units for numeric values when the parameter represents a physical quantity, such as length. The literal 3' 0" represents 3 feet, 0 inches. A comparison between a length parameter and a bare number can fail because the values do not have compatible units.
Useful Revit IF formula examples
For each example, create a formula parameter with the appropriate data type, then enter the expression in its Formula field. The parameter names and thresholds are examples; adapt them to the dimensions and naming conventions in your family.
- Return a text label: With Width as a Length parameter and a result parameter named Size Label set to Text, enter
if(Width > 3' 0", "Wide", "Narrow"). The result is “Wide” above 3 feet and “Narrow” at or below 3 feet. - Return a length: With Width as a Length parameter and a result parameter named Frame Depth also set to Length, enter
if(Width > 3' 0", 4' 0", 2' 0"). If Width is 3 feet 6 inches, Frame Depth evaluates to 4 feet; at 3 feet or less, it evaluates to 2 feet. - Return a yes/no result: With Width as a Length parameter and a result parameter named Is Wide set to Yes/No, enter
if(Width > 3' 0", true, false). Is Wide becomes Yes above 3 feet and No at or below the threshold. - Choose between numeric values: With a Number parameter named Load and a Number result parameter named Factor, enter
if(Load > 100, 1.5, 1). A Load of 120 produces 1.5; a Load of 100 or less produces 1. - Check two conditions: With Width and Height as Length parameters and a Text result parameter named Opening Class, enter
if(and(Width > 3' 0", Height > 7' 0"), "Large", "Standard"). The result is “Large” only when both dimensions exceed their thresholds.
For the last example, and requires both tests to be true. Revit also supports or for a condition where either test may be true, and not to reverse a logical result. Use these logical functions inside the IF condition when the decision depends on more than one comparison.
Choose the right parameter type
Before writing a formula, decide what kind of value it should return. Revit parameters are typed: length, area, volume, angle, number, integer, text, and yes/no values are not interchangeable. A formula that returns the text “Wide” belongs in a Text parameter, not a Length parameter. A formula that selects between two dimensions belongs in a Length parameter.
For numeric quantities, make the alternatives meaningful in the parameter’s units. A formula that returns a length should use length values in both branches; a formula that returns a Number should return numbers. If the two alternatives have different types, or the condition compares incompatible quantities, Revit may report an error rather than evaluate the formula. Setting the parameter type correctly at creation is usually easier than trying to repair a type mismatch later.
Think about the boundary as well. In if(Width > 3' 0", "Wide", "Narrow"), a width of exactly 3 feet is “Narrow,” because the test uses greater than, not greater than or equal to. If exactly 3 feet should count as wide, change the operator to >=.
Enter a formula in the Family Types dialog
- Open the family in the Family Editor and open the Family Types dialog from the family properties controls.
- Create or identify the input parameter, such as Width, and create a result parameter with the correct data type. Choose whether each parameter should be a type or instance parameter based on how the family is intended to be controlled.
- In the result parameter’s Formula column, type the expression without a leading equals sign. Check that the parameter names match and that quotes, commas, parentheses, and units are in place.
- Click Apply or test the family type values in the dialog. Change the input value and confirm that the result changes at the expected threshold.
- Load or reload the family into a project when the family behaves as intended, then check representative types or instances in the project.
To use a formula-driven yes/no parameter for geometry visibility, select the relevant geometry in the family, locate its Visible property, and use the Associate Family Parameter control beside that property. Associate it with the yes/no parameter whose formula returns true or false. This keeps the geometry’s visibility linked to the condition rather than requiring a user to switch it manually.
Combining conditions and using nested IFs
Use and(condition1, condition2) when every condition must be met, and or(condition1, condition2) when any one of them is enough. For example, a family might label an opening “Large” only if it is both wider than 3 feet and taller than 7 feet. If either dimension alone should trigger the label, replace and with or. Choosing the correct logic is a design decision: the formula can be syntactically valid while still expressing the wrong rule.
For more than two possible outcomes, IF functions can be nested: the false result of one IF can itself be another IF. A conceptual size classification might return one label above a high threshold, a second label above a lower threshold, and a third label otherwise. Keep nested expressions readable by laying out the decisions on paper first, and test values just below, at, and above every threshold. If the formula becomes difficult to maintain, separate the logic into intermediate parameters with clear names rather than putting every decision into one long expression.
Common formula errors and how to fix them
- Starting with an equals sign: Family formulas do not use Excel’s leading
=. Enterif(...), not=if(...). - Wrong result parameter type: Confirm that a text result is assigned to a Text parameter, a Boolean result to Yes/No, and dimensions to a compatible physical-quantity parameter.
- Missing or inconsistent units: Add appropriate unit notation to literal dimensions and compare quantities of the same kind. Check the project or family’s unit expectations when a value is interpreted unexpectedly.
- Incorrect punctuation: IF requires three arguments, separated by commas, with balanced parentheses. Text values need straight double quotes; typographic curly quotes copied from formatted text may not parse.
- Unexpected threshold result: Review whether the condition uses
>or>=, and test the exact boundary. A width equal to the threshold does not satisfy a strict greater-than test. - Dependent parameters conflict: A formula can create a circular dependency if the result parameter also drives an input used to calculate that result. Make the direction of dependence one-way and inspect other constraints or formulas that affect the same values.
When Revit rejects a formula, simplify it temporarily. First test the comparison, then the IF with simple outputs, and finally restore the intended values. This isolates whether the issue is the condition, the output type, unit notation, or a parameter dependency.
Family formulas versus schedule calculations
A family formula is evaluated inside a family and can drive family parameters, dimensions, labels, or visibility. A schedule calculated value is created while editing a schedule and calculates from fields available in that schedule. The two features solve related but distinct problems: use a family formula when an object’s behavior should respond to its own parameters, and a schedule calculation when you need a derived value for tabulated project information.
For example, a door family can use an IF formula to switch a yes/no visibility parameter based on its width. A project schedule could instead calculate or display information for a group of doors using schedule fields. A schedule calculation does not automatically become a family parameter, and a family formula is not a substitute for every project-wide schedule calculation.
Frequently Asked Questions
Does a Revit IF formula start with an equals sign?
No. Enter the expression directly, such as if(Width > 3' 0", true, false). The leading equals sign is familiar from spreadsheets, but it is not used for a Revit family parameter formula.
Can an IF formula return text in Revit?
Yes. Put each text result in straight double quotation marks and use a Text parameter for the formula result, for example if(Width > 3' 0", "Wide", "Narrow").
Can an IF formula control family visibility?
Yes. Have a formula calculate a Yes/No parameter, then associate that parameter with the Visible property of the family geometry. The formula’s true or false result controls the visibility setting.
Can I use more than one condition?
Yes. Combine comparisons with and when all must be true or or when any can be true. You can also nest IF functions for several possible outcomes, but test each boundary and keep complicated logic understandable.
Why does Revit say my formula has an error?
Common causes include a mismatched parameter type, missing units, incorrect parameter spelling, curly quotation marks, unbalanced parentheses, or an invalid dependency between parameters. Check the result type and simplify the formula to identify the failing part.
Related
- Excel Data Validation Images: What Works and How to Do It
- Excel Data Validation Examples for Better Data Entry
- Excel Data Validation Colour Change: Rules and Fixes
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- PMT Function in SQL: Calculate Loan Payments by PeriodSQL does not have a universally available built-in PMT function. To calculate a fixed loan payment, use the…
- Power Query Find Text in a String: M Functions and ExamplesTo find whether a Power Query text value contains a word or phrase, use Text.Contains. In a Custom…
- Excel IF Formula Examples: Tests, Logic, and ErrorsExcel’s IF formula checks whether a condition is true or false and returns one result for each outcome.…
- Excel Formula Not Calculating? Common Causes and FixesIf a formula will not calculate in Excel, check that the cell is not formatted as Text, that…
- Unique in Excel: Get Values Without DuplicatesTo list each value once in Excel for Microsoft 365, enter =UNIQUE(A2:A10) in an empty cell, replacing A2:A10…
- SUMIF in Excel: Examples and How to Use ItExcel’s SUMIF function adds values that meet one condition. For example, with product names in A2:A7 and sales…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.