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:

OperatorDescriptionExample
+AdditionPrice+Tax
-SubtractionTotal-Discount
*MultiplicationQuantity*Price
/DivisionTotal/People
^ExponentiationBase^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:

FunctionDescriptionExample
SUMSum of all argumentsSUM(Value1,Value2,Value3)
AVGAverage of all argumentsAVG(Score1,Score2,Score3)
MINMinimum valueMIN(Price1,Price2,Price3)
MAXMaximum valueMAX(Score1,Score2,Score3)
ROUNDRound to specified decimal placesROUND(Price, 2)
IFConditional logicIF(Age >= 18, 10, 20)

Conditional Logic

The IF function allows you to create conditional logic in your formulas. It takes three arguments:

  1. A condition to evaluate (returns true or false)
  2. Numeric value to return if the condition is true
  3. 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:

IF(Total > 1000, Total * 0.9, Total)

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

Quantity*Price+(Quantity*Price*TaxRate)

Calculates the total cost including tax based on quantity, price, and tax rate.

Discount Calculator

Price-(Price*DiscountPercentage/100)

Calculates the price after applying a percentage discount.

BMI Calculator

Weight/((Height/100)^2)

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.