Formula Engine
Formula Expression Engine
LotusGen allows custom column derivations and conditional filtering through a secure AST sandbox that evaluates expressions without unsafe eval() calls.
Intra-Table Dependencies
A function column can reference any column defined above it in the table schema. The intra-table DAG automatically validates column evaluation order and rejects circular references.
Supported Syntax & Functions
Arithmetic Operators
- Addition:
+ - Subtraction:
- - Multiplication:
* - Division:
/ - Floor Division:
// - Modulo:
% - Power:
**
Comparison Operators
- Equality:
==,!= - Inequality:
<,<=,>,>=
Logical Operators
- Conjunction:
and - Disjunction:
or - Inversion:
not
Built-in Mathematical Functions
abs(x): Absolute valueround(x, n): Round number tondecimal placesmin(a, b): Minimum of valuesmax(a, b): Maximum of valuessqrt(x): Square root
Ternary Conditionals
Python-style inline ternary expressions are fully supported:
value_if_true if condition else value_if_falseFormula Examples
Price Calculation with Tax
round(unit_price * (1 + tax_rate), 2)Customer Tier Segmentation
'VIP' if total_spend > 1000 else 'Regular'Full Name Concatenation
first_name + ' ' + last_nameConditional Row Filtering (exclude_if)
Tables support an optional exclude_if formula. When generating data, if exclude_if evaluates to True for a given row, that row is omitted from the output stream:
# Example: Exclude inactive trial users with zero activity
status == 'trial' and login_count == 0