max()
Return the largest number from a list of values — useful for minimum charges, non-negative totals, and “never less than X” business rules.
Syntax
Every formula in Calcopolis must start with = in the Value field:
= max(value1, value2, ...)
| Part | Rule |
|---|---|
| Function name | max — lowercase |
| Arguments | Two or more, separated by commas |
| Argument types | Numbers, variable Names, or expressions |
| Return value | The highest argument after evaluation |
Valid examples
= max(0, balance_due)
= max(min_order_fee, subtotal * 0.02)
= max(standard_price, floor_price)
= max(qty - free_units, 0)
Invalid / unsupported
| Don't write | Why |
|---|---|
max(a; b) |
Use commas ,, not semicolons |
MAX(qty, 0) |
Function name is lowercase max |
{{ max(0, x) }} in a Result widget |
Results use = only — {{ }} is for Custom Text and Table |
Parameters
| Argument | Description |
|---|---|
value1, value2, … |
Each value to compare. Literal, variable, or expression. |
| (two or more) | Pass at least two values; max returns the largest after evaluation. |
When to use max()
Use max() when a value needs a floor or you want the better of two options:
| Situation | What max() does |
|---|---|
| Non-negative totals | Prevent negative balances: max(0, subtotal - credit) |
| Minimum order fee | Charge at least $25 even on small orders |
| Tier pricing | Pick the higher of calculated price and list price |
| Billable units | Only charge for units above a free allowance |
Pair with [min()](/docs/reference/formulas/min-function/) to clamp a value into a range: = max(0, min(fee, cap)).
Practical examples (ecommerce & leads)
1. Minimum service fee
| Variable | Formula |
|---|---|
calculated_fee |
= hours * hourly_rate |
service_fee |
= max(calculated_fee, min_service_fee) |
Show service_fee on a Result widget.
2. Free shipping threshold messaging
| Variable | Formula |
|---|---|
amount_to_free_shipping |
= max(0, free_shipping_threshold - cart_total) |
Use in Custom Text when amount_to_free_shipping > 0.
3. Billable quantity after free units
| Variable | Formula |
|---|---|
billable_qty |
= max(qty - included_units, 0) |
line_total |
= billable_qty * unit_price |
4. Lead score floor
| Variable | Formula |
|---|---|
lead_score |
= max(base_score + bonus_points, 0) |
Keeps displayed score non-negative for dashboard-style Result widgets.
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.
Related
- [
min()](/docs/reference/formulas/min-function/) - Understanding Formulas and Variables —
=syntax and variables - Building Your First Calculator — end-to-end quote calculator