Conditionals & Logic

Conditional expressions and nested logic patterns.

The if() function allows conditional logic in your formulas. It evaluates a condition and returns one of two values.

Basic Conditional

If(condition; valueIfTrue; valueIfFalse)

Examples:
If($width > 1000; $width * 1.1; $width)    → add 10% surcharge
If($material == "steel"; 7.85; 2.7)         → density by material

Nested Conditionals

You can nest if() calls for multi-tier logic (e.g., tiered pricing, material-dependent factors).

If($width > 2000;
  $width * 1.2;
  If($width > 1000;
    $width * 1.1;
    $width
  )
)   → tiered pricing

Case — Multi-Branch Conditional

Case() works like a switch/case statement. The first argument is the expression to match, followed by pairs of value;result, and a final default value when nothing matches.

Case(expr; val1; result1; val2; result2; ...; default)

First argument is the expression to match, then pairs of value;result.
The last argument is the default when no value matches.

Example:
Case($Profile; "Milan"; 13; "Milan Slim"; 12; 0)
→ returns 13 when $Profile is "Milan", 12 when "Milan Slim", 0 otherwise

Common Patterns

  • Surcharge: If($width > 1000; $price * 1.1; $price) — 10% extra for large sizes.
  • Material factor: If($material == "steel"; 7.85; 2.7) — density lookup by material.
  • Minimum quantity: max($count; 1) — ensure at least 1.
  • Safe division: If($d != 0; $v / $d; 0) — avoid division by zero.
  • Boolean toggle: If($hasDoor == 1; $doorPrice; 0) — optional component pricing.
  • Multi-branch: Case($Profile; "Milan"; 13; "Milan Slim"; 12; 0) — switch by profile name.

Deeply nested If() can become hard to read. Use Case() for multi-branch logic, or split complex logic into multiple calculation rows.

We use cookies for analytics to improve your experience. Privacy Policy