Skip to content

Calculated formulas

FLEX
Included

Validated calculations, dependency-aware formulas and server-calculated form values.

FIELD INTELLIGENCE

Inputs become answers.

Build calculations from validated inputs, connect their dependencies and recalculate results before saving. Explore the workspace, then try five complete workflows.

Validated inputsOrdered dependenciesServer-calculated outputsFunction policies

Formula workspace

Write a formula with a, b and c. Inspect its references, allowed functions and validation without saving anything.

Try if({b}>0,{a}/{b},0). PHP, JavaScript and undeclared references are rejected.
Valid expression
Result408 round({a}*{b}*(1-pct({c})),2)
Referencesa, b, cFunctionspct, round

Invoice & tax

Calculate rounded tax and discounts in cents. Change an input to see the complete calculation update.

€
Calculation ready 5 connected outputs
Subtotal €599.97 {price}*{quantity}
Discount €60.00 round({subtotal}*pct({discount}),0)
Net amount €539.97 {subtotal}-{discount_amount}
Tax €124.19 round({net}*pct({tax}),0)
Invoice total €664.16 {net}+{tax_amount}
Calculation order
  1. subtotalprice · quantity
  2. discount_amountsubtotal · discount
  3. netsubtotal · discount_amount
  4. tax_amountnet · tax
  5. totalnet · tax_amount

Tiered pricing

Use conditions for volume discounts and free shipping. A single input can update several dependent totals.

€
€
Calculation ready 4 connected outputs
Volume discount 10.00% if({quantity}>=20,15,if({quantity}>=10,10,0))
After discount €486.00 round({price}*{quantity}*(1-pct({discount_rate})),0)
Shipping €15.00 if({net}>=50000,0,{shipping})
Order total €501.00 {net}+{delivery}
Calculation order
  1. discount_ratequantity
  2. netprice · quantity · discount_rate
  3. deliverynet · shipping
  4. totalnet · delivery

Progress & safe division

A zero target is valid here: the conditional formula skips division and returns zero. Progress stays between 0% and 100%.

Calculation ready 3 connected outputs
Remaining 6 max({target}-{completed},0)
Progress 75.00% if({target}>0,clamp(round({completed}/{target}*100,2),0,100),0)
Target reached No and({target}>0,{completed}>={target})
Calculation order
  1. remainingtarget · completed
  2. progresstarget · completed
  3. completetarget · completed

Profit & margin

Calculate profit and margin from the same inputs. Revenue can be zero without producing a division error.

€
€
Calculation ready 3 connected outputs
Profit €4,200.00 {revenue}-{cost}
Margin 35.00% if({revenue}>0,round({profit}/{revenue}*100,2),0)
Profitable Yes {profit}>0
Calculation order
  1. profitrevenue · cost
  2. marginrevenue · profit
  3. profitableprofit

Stock & replenishment

Combine capacity limits, thresholds and whole-number rounding to calculate the next purchase order.

Calculation ready 4 connected outputs
Unreserved stock 10 max({stock}-{reserved},0)
Shortfall 50 max({target}-{available},0)
Packs to order 5 ceil({shortfall}/{pack})
Units to purchase 60 {packs}*{pack}
Calculation order
  1. availablestock · reserved
  2. shortfalltarget · available
  3. packsshortfall · pack
  4. purchasepacks · pack

Calculated fields in a real form

These are actual bound FLEX fields. The disabled total updates live and is recalculated again when the form is dehydrated for saving. Invalid inputs cannot produce a saved total.

round({price}*{quantity},2)

Dependencies & incremental updates

See which outputs depend on each other and what actually changes when an input changes. Cycles are rejected before evaluation.

Acyclic graph — ready
subtotal480{price}*{quantity} Price 120 → 150: 600
tax110.4round({subtotal}*pct({rate}),2) Price 120 → 150: 138
total590.4{subtotal}+{tax} Price 120 → 150: 738

Execution order: subtotal → tax → total

Validation & tamper protection

The input contract accepts integers from 0 to 100. Invalid payloads expose no calculated outputs. A forged result is recalculated from the inputs.

Accepted — result calculated on the server
Submitted payload{"input":20}40
Loading code examples…

Information

Developer
FLEX
Category
Guides
Website