You can use calculation fields in Smartabase to perform calculations using the data captured using forms. When you add a calculation field, you can use the Calculation tab to write equations.
Equations are based on a similar model to Microsoft Excel: you can reference fields within forms and use some standard notation or built-in functions to return a new value. It's important to understand what data you expect from a calculation and choose the appropriate calculation and functions, otherwise the calculation may fail or not work as expected.
Operators and order of operations
You can use standard operators to perform general calculations.
- + for addition
- - for subtraction
- * for multiplication
- / for division
As with Excel, and other programming languages, use the standard order of operations to perform calculations so that the following precedence exists:
- Exponents and roots
- Multiplication and division
- Addition and subtraction
Brackets can also be used to split up a calculation; operators within brackets are performed before operators outside of brackets. For example:
3 + 4 * 2
This would return 11, since the multiplication occurs before the addition. However, the example below would return 14, since the addition within brackets occurs before multiplication.
(3 + 4) * 2
In addition to the standard operators, Smartabase also has many built-in functions that can be used. You can choose basic functions like sum, min and max as well as more advanced functions like log or sqrt. To see a full list for each calculation type, select the Available Functions drop-down at the bottom of the Calculation tab. You can select the tooltip to see details about a specific calculation.
When building a form, fields and calculations need to be ordered according to the sequence in which they should be populated. For example, a calculation which averages two number fields should be displayed after the number fields.