if() Function

Return one value when a condition is true and another when it is false — the core of tiered pricing and conditional quotes.

formulas functions if conditional

if()

Evaluate a condition and return one of two values — essential for tiered discounts, optional add-ons, and branching quote logic without duplicating widgets.


Syntax

Every formula in Calcopolis must start with = in the Value field:

= if(condition, value_if_true, value_if_false)
Part Rule
Function name if — lowercase
Arguments Exactly three, separated by commas
Condition Any expression that evaluates to true (non-zero) or false (zero)
Return value Second argument if true, third if false

Valid examples

= if(qty >= 10, subtotal * 0.1, 0)
= if(is_rush, rush_fee, 0)
= if(plan_type == 1, monthly_price_a, monthly_price_b)
= if(subtotal > 500, 0, shipping_cost)

Invalid / unsupported

Don't write Why
if qty > 10 then 5 else 0 Use if(condition, true_value, false_value) syntax
IF(x, 1, 0) Function name is lowercase if
if(x, y) All three arguments are required

Parameters

Argument Description
condition Comparison or expression. Examples: qty >= 10, selected_plan == 2, subtotal > budget.
value_if_true Returned when the condition is true (non-zero).
value_if_false Returned when the condition is false (zero).

When to use if()

Use if() whenever the formula should branch:

Situation What if() does
Volume discounts 10% off only when qty >= 10
Optional fees Add rush fee when a Checkbox is selected
Plan tiers Different monthly price per Radio / Select choice
Free shipping Shipping cost is zero above a cart threshold

For complex tier tables, combine several if() calls or use intermediate variables on the Variables tab.


Practical examples (ecommerce & leads)

1. Volume discount on subtotal

Variable Formula
discount = if(qty >= 10, subtotal * 0.1, 0)
you_pay = subtotal - discount

2. Rush processing surcharge

is_rush comes from a Checkbox (1 when checked, 0 when not).

Variable Formula
rush_fee = if(is_rush, 49, 0)
order_total = subtotal + rush_fee

3. Tiered price per seat band

team_size from a Number field.

Variable Formula
per_seat_rate = if(team_size >= 50, 8, if(team_size >= 10, 12, 15))
monthly_cost = team_size * per_seat_rate

Nested if() is valid — keep conditions readable with named intermediate variables when possible.

4. Conditional shipping in ecommerce quote

Variable Formula
shipping = if(subtotal >= 75, 0, 9.99)
grand_total = subtotal + shipping

Where to use it

Location Supported
Result widget Value Yes — = ... formulas
Standalone variable (Variables tab) Yes
Number / other input default Value Yes, if formula-driven
Visibility formula Yes
Custom Text / Table cells No — use {{ }} templates there, not = functions

After editing, run Calculate (or enable Run calculation on load in project Options) to refresh results.


← Back to Reference

Still have unanswered questions?

We are here to help. Reach out and our team will get back to you.

Contact support