Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.opnform.com/llms.txt

Use this file to discover all available pages before exploring further.

Computed variables allow form owners to define calculated values using formulas. These variables can reference form fields, use functions, and even reference other computed variables. They work seamlessly with mentions throughout your form.

Overview

Computed variables are powerful calculated fields that:
  • Evaluate live during form fill (client-side)
  • Evaluate on submission for integrations and notifications (server-side)
  • Support Excel-like formulas with math, text, and logic functions
  • Chain together to create complex calculations
  • Work with mentions anywhere you can use field references

Creating Computed Variables

Accessing the Variables Tab

  1. Open your form in the editor
  2. Click on Settings (gear icon)
  3. Navigate to the Variables tab
  4. Click Add Variable to create a new computed variable

Variable Configuration

Each computed variable has:
FieldDescription
NameA descriptive name for the variable (e.g., “Total Price”)
FormulaThe calculation formula using fields, functions, and operators

Formula Editor

The formula editor provides:
  • Field picker - Insert form fields as references
  • Function picker - Browse and insert available functions
  • Live validation - Real-time syntax checking
  • Preview - See sample output as you type

Formula Syntax

Field References

Reference form fields using curly braces:
{field_id}
In the editor, you can click the field button to insert fields as interactive pills.

Operators

OperatorDescriptionExample
+Addition / Concatenation{price} + {tax}
-Subtraction{total} - {discount}
*Multiplication{price} * {quantity}
/Division{total} / {count}
=Equals{status} = "active"
<>Not equals{status} <> "inactive"
< >Less/Greater than{age} > 18
<= >=Less/Greater or equal{score} >= 90

Text Concatenation

Use + or CONCAT() to join text:
"Hello, " + {name} + "!"
CONCAT({first_name}, " ", {last_name})

Available Functions

Math Functions

FunctionDescriptionExample
SUM(...)Add multiple valuesSUM({item1}, {item2}, {item3})
AVERAGE(...)Calculate meanAVERAGE({score1}, {score2})
MIN(...)Find minimumMIN({price1}, {price2})
MAX(...)Find maximumMAX({bid1}, {bid2})
ROUND(value, decimals)Round numberROUND({total}, 2)
FLOOR(value)Round downFLOOR({price})
CEIL(value)Round upCEIL({quantity})
ABS(value)Absolute valueABS({difference})
MOD(value, divisor)RemainderMOD({number}, 2)
POWER(base, exp)ExponentiationPOWER({base}, 2)
SQRT(value)Square rootSQRT({area})

Text Functions

FunctionDescriptionExample
CONCAT(...)Join textCONCAT({first}, " ", {last})
UPPER(text)UppercaseUPPER({name})
LOWER(text)LowercaseLOWER({email})
TRIM(text)Remove whitespaceTRIM({input})
LEFT(text, n)First n charactersLEFT({code}, 3)
RIGHT(text, n)Last n charactersRIGHT({phone}, 4)
MID(text, start, len)SubstringMID({ssn}, 4, 2)
LEN(text)Text lengthLEN({message})
SUBSTITUTE(text, old, new)Replace textSUBSTITUTE({url}, "http", "https")
REPT(text, n)Repeat textREPT("*", {rating})

Logic Functions

FunctionDescriptionExample
IF(condition, true_val, false_val)ConditionalIF({score} >= 90, "A", "B")
AND(...)All trueAND({age} >= 18, {consent})
OR(...)Any trueOR({premium}, {trial})
NOT(value)NegateNOT({disabled})
ISBLANK(value)Check emptyISBLANK({optional})
ISNUMBER(value)Check numberISNUMBER({input})
ISTEXT(value)Check textISTEXT({response})
IFBLANK(value, fallback)Default if emptyIFBLANK({nickname}, {name})
COALESCE(...)First non-emptyCOALESCE({mobile}, {home}, {work})
SWITCH(val, case1, res1, ...)Multiple conditionsSWITCH({grade}, "A", 4, "B", 3, 0)
CHOOSE(index, val1, val2, ...)Pick by indexCHOOSE({option}, "One", "Two", "Three")

Common Use Cases

Calculate Total Price

{price} * {quantity}

Apply Discount

{subtotal} * (1 - {discount_percent} / 100)

Calculate Tax and Total

// Tax variable
{subtotal} * 0.1

// Total variable (referencing tax)
{subtotal} + {cv_tax}

Conditional Pricing

IF({membership} = "premium", {price} * 0.8, {price})

Grade Calculator

IF({score} >= 90, "A", 
  IF({score} >= 80, "B", 
    IF({score} >= 70, "C", 
      IF({score} >= 60, "D", "F"))))

Full Name

CONCAT({first_name}, " ", {last_name})

Email Domain

RIGHT({email}, LEN({email}) - FIND("@", {email}))

Using Computed Variables

In Mentions

Computed variables appear in the mention dropdown alongside form fields. Look for the 📊 icon:
  • In Thank You Page content
  • In Email notifications (subject, body, reply-to)
  • In Redirect URLs
  • In Integration payloads

In Conditional Logic

Use computed variables in conditional logic rules:
  1. Open the Logic tab for a field
  2. Add a condition
  3. Select your computed variable from the dropdown
  4. Set the comparison operator and value
Example: Show a field only when total is over $100:
  • Field: cv_total
  • Condition: greater_than
  • Value: 100

Variable Dependencies

Computed variables can reference other computed variables:
// cv_subtotal
{price} * {quantity}

// cv_tax (references cv_subtotal)
{cv_subtotal} * {tax_rate}

// cv_total (references both)
{cv_subtotal} + {cv_tax}
Circular Dependencies: The system automatically detects and prevents circular references. Variable A cannot reference Variable B if B already references A (directly or indirectly).

Technical Details

Evaluation Timing

ContextWhen Evaluated
Form fillLive, as field values change
Conditional logicBefore rendering each field
Thank you pageAfter submission
Email notificationsWhen email is sent
IntegrationsWhen integration runs

Data Storage

Computed variable values are not stored in submission records. They are calculated on-demand when needed. This ensures:
  • Always up-to-date calculations
  • Smaller database storage
  • Formula changes affect past submissions when viewed

Error Handling

If a formula cannot be evaluated (e.g., division by zero, missing field), it returns null. Use IFBLANK() or COALESCE() to provide fallback values:
IFBLANK({cv_calculation}, "N/A")

Best Practices

Naming: Use descriptive names like “Total Price” or “Shipping Cost” rather than generic names like “Calculation 1”.
Validation: Test your formulas with sample data using the preview feature before saving.
Modularity: Break complex calculations into smaller variables that reference each other. This makes formulas easier to understand and debug.
Performance: While computed variables are efficient, avoid extremely complex chains of 10+ interdependent variables for best performance.