Put the result in Data
A dataFormula declares a result path, a calculation and named inputs. Other elements bind to that result rather than duplicating the arithmetic. This makes a chain such as subtotal → discount → total visible in the source.
This positional Python example is a small inline JavaScript expression. It illustrates the relationship in the gallery’s permissive profile. Named Logic, introduced in lesson 08, is used by the strict scaffold.
pane.dataFormula(
".total", "price * quantity",
price="^.price", quantity="^.quantity",
_init=True
)A sampled input is a choice
In the Formula gallery lesson, a gross calculation reads VAT with =. Changing VAT alone does not recalculate that result. Changing a reactive input afterwards reads the new VAT. _init requests the initial calculation.
For your own estimate, make every business dependency reactive when that is the required behavior. The example’s sampled VAT is an experiment about triggers, not a universal pricing rule.
Your turn
Try it yourself
- Open Formula and record the inputs and displayed results.
- Change VAT alone and note which results stay unchanged.
- Change quantity, then explain which VAT value the next calculation reads.
Check your understanding
Where should a displayed total read its value?
Show the answer and expected result
From the formula’s result path in Data. The arithmetic is declared once, and any number of displays can bind to the result. Avoid putting a result inside the same collection being aggregated.