random()
Return a random decimal between 0 and the given upper bound — handy for sample dashboards, what-if demos, and calculators that illustrate variability (not for cryptographic or compliance use).
Syntax
Every formula in Calcopolis must start with = in the Value field:
= random(n)
| Part | Rule |
|---|---|
| Function name | random — lowercase |
| Arguments | One — the upper bound n |
| Return value | A decimal in the range 0 ≤ result < n (changes on each Calculate) |
Valid examples
= random(100)
= random(1)
= base_estimate * (1 + random(10) / 100)
Invalid / unsupported
| Don't write | Why |
|---|---|
random() |
n is required |
random(10, 20) |
Only one argument — use expressions for offsets: 5 + random(10) |
Expecting integers only |
Result is a decimal; wrap with roundTo() if you need whole numbers |
Parameters
| Argument | Description |
|---|---|
n |
Upper bound (exclusive in practice for fractional outputs). random(100) yields roughly 0–100. |
When to use random()
Use random() for non-deterministic demos, not production pricing:
| Situation | What random() does |
|---|---|
| ROI simulators | Show a band of possible returns |
| Training calculators | Sample values on each run |
| A/B style demos | Illustrate variance in lead volume forecasts |
Each Calculate click produces a new value. For fixed quotes, use real inputs instead of random().
Practical examples (ecommerce & leads)
1. Simulated conversion uplift band
| Variable | Formula |
|---|---|
uplift_pct |
= random(15) |
projected_leads |
= roundTo(base_leads * (1 + uplift_pct / 100), 0) |
2. Demo “savings today” widget
| Variable | Formula |
|---|---|
savings_demo |
= roundTo(random(500) + 100, 2) |
Label clearly in Custom Text that figures are illustrative if used on a public page.
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
- [
roundTo()](/docs/reference/formulas/round-to-function/) - Understanding Formulas and Variables —
=syntax and variables - Building Your First Calculator — end-to-end quote calculator