Formula Editor Guide
Learn how to use Minivolve's formula editor to create powerful calculations for your apps.
Introduction to the Formula Editor
The formula editor is a powerful component of Minivolve that allows you to create dynamic calculations based on user inputs. With the formula editor, you can perform everything from simple arithmetic to complex conditional calculations without writing any code.
Formulas in Minivolve are created using a token-based system where each element (field reference, operator, or number) is represented as a distinct token with its own visual styling and behavior. This makes creating and editing formulas intuitive and error-free.
Formula Editor Interface
The formula editor interface consists of several key components:
- Formula Expression Area - Where you build and edit your formula
- Field Selector - Dropdown to select fields from your app
- Results Selector - Dropdown to reference other result fields
- Functions Dropdown - List of available functions to use
- Operator Panel - Quick access to mathematical operators
When working with the formula editor, you'll add tokens (fields, operators, numbers) to build your calculation. Each token is visually distinct, making it easy to understand the structure of your formula at a glance.
Basic Operations
The formula editor supports all standard arithmetic operations:
Operator | Description | Example |
---|---|---|
+ | Addition | Price+Tax |
- | Subtraction | Total-Discount |
* | Multiplication | Quantity*Price |
/ | Division | Total/People |
^ | Exponentiation | Base^2 |
( ) | Parentheses | (Price+Tax)*Quantity |
Operator precedence follows standard mathematical rules (PEMDAS). Use parentheses to control the order of operations explicitly.
Functions
Minivolve's formula editor includes several built-in functions to handle common calculations:
Function | Description | Example |
---|---|---|
SUM | Sum of all arguments | SUM(Value1,Value2,Value3) |
AVG | Average of all arguments | AVG(Score1,Score2,Score3) |
MIN | Minimum value | MIN(Price1,Price2,Price3) |
MAX | Maximum value | MAX(Score1,Score2,Score3) |
ROUND | Round to specified decimal places | ROUND(Price, 2) |
IF | Conditional logic | IF(Age >= 18, 10, 20) |
Conditional Logic
The IF function allows you to create conditional logic in your formulas. It takes three arguments:
- A condition to evaluate (returns true or false)
- Numeric value to return if the condition is true
- Numeric value to return if the condition is false
Important: Both true and false values must be numbers, not text strings. For example, use IF(Age >= 18, 10, 20)
instead of IF(Age >= 18, "Adult", "Minor")
.
Example:
This formula applies a 10% discount if the total is greater than 1000, otherwise returns the original total. Note that both return values are numeric, which is required for the IF function.
You can use various comparison operators in your conditions:
==
(Equal to)!=
(Not equal to)>
(Greater than)<
(Less than)>=
(Greater than or equal)<=
(Less than or equal)Formula Examples
Here are some practical examples of formulas for common use cases:
Basic Price Calculator
Calculates the total cost including tax based on quantity, price, and tax rate.
Discount Calculator
Calculates the price after applying a percentage discount.
BMI Calculator
Calculates Body Mass Index (BMI) using weight in kg and height in cm.
Tips for Working with Formulas
Break Complex Formulas into Multiple Results
Instead of creating one large, complex formula, consider breaking it into multiple result fields that reference each other.
Use Parentheses Liberally
Even when not strictly necessary, parentheses can make your formulas easier to read and understand.
Test Your Formulas
Always test your formulas with various input values to ensure they work correctly in all scenarios.
Handle Edge Cases
Use IF functions to handle potential edge cases, such as division by zero or negative inputs.
Keep Formulas Readable
While our token-based system helps with readability, still try to keep your formulas as simple and clear as possible.
Ready to Create Your Own Formulas?
Start building your calculator with powerful formulas to create dynamic, interactive experiences for your users.