Table of Contents |
---|
Purpose
Formula editor is used to create Visualization and Calculation rules for fields. You can access it by creating new field or editing and existing field in the Form Designer. At the bottom of the screen you can choose either to add Calculation or Visualization rule for the chosen field by clicking Edit. Some Fields may have only Visualization rule available if they can't be used in calculations.
Default View
Reference | Description |
---|---|
1 | Expression builder |
2 | Available fields for selection |
3 | Arithmetic and logical operators |
4 | Available functions |
5 | Available options in pick list and multi-select fields |
If you click once on a Pick List or Mulit-Select Field, their available options will appear on the empty place bellow the operator’s buttons. Options will also display if the pick list / multi-select field is based on a data source URL setting (i.e. Technician or Location).
Expression building
To add a field or function to expression builder you have 2 options:
- To click twice on selected field/function
- Start writing it and the expression builder will hint you if there is match
When a function is inserted it will provide additional information about how the function must be structured.
Functions
At the moment there are 11 available functions:
- SQR(number, power) - returns a number by a chosen power. Here we can choose a static number, like SQR(2, 3) and to get as return 8, or we can choose from a number Fields in our Form - SQR(Result1, Result2). Of course there can be a mixes - SQR(2, Result1), SQR(Result2, 3). The important part is that used fields must be number type and that the power must be with integer value.
- SQRT(number) - returns square root of a number or chosen Field - SQRT(4), SQRT(Result1). Again the Field must be number type.
- MIN(Value1, Value2,…) - return the smallest number from a list of numbers. The rules remain the same - numbers or fields from number type.
- MAX(Value1, Value2,…) - return the biggest number. Same rules.
- AVG(Value1, Value2,…) - return the average of the chosen number. Same rules.
- SUM(Value1, Value2,…) - return the sum of the chosen number. Same rules.
- ROUND(Value, Optional: Precision) - Rounds a number. If no Precision is entered the default behavior will be rounding to integer - ROUND(4.5) = 5, ROUND(4.44456) = 4. But if we want rounding to second digit after the decimal separator we must do ROUND(4.44456, 2) = 4.44. Of course same rules, as applied till now, are valid so ROUND(Result1, Result2) will be a valid expression too.
- ROUNDTOEVEN(Value) - Rounds a number to closest even value - ROUNDTOEVEN(5.4999) = 4, ROUNDTOEVEN(5.500001) = 6
- HASVALUE(Value) - returns "true" if the selected field has value and "false" if not. HASVALUE(Result1) - if there is anything entered in Result1 the result will be true. You can choose that expression if you want some field(s) to be visible only if specific field have some value.
- CONTAIN(Field, Value) - you can used this function if you want some field(s) to be visible only if specific Option from a Multi or Pick list is selected. To be working you must choose as Field the Pick/Multi List and as Value the option as string(in ""). For example : CONTAIN(PickList, "Pass"). If you want to assure that there is no mistakes in your expressions just double click on hint words and replace them with provided fields/options. If you want you fields to be visible when two options are selected(available only in Multilist) you can combine two CONTAIN function, or any other:
CONTAIN(MultiList, "Option 1") AND CONTAIN(MultiList, "Option 2") OR CONTAIN(MultiList, "Option 3")
Every possible logical operators can be applied and if you want to change the priority just add parenthesis where necessary:
CONTAIN(MultiList, "Option 1") AND (CONTAIN(MultiList, "Option 2") OR CONTAIN(MultiList, "Option 3"))
- IF(Condition, ThenValue, Optional: ElseValue) - With If/Then/Else function you can decide what to be the value of the selected field, depending on chosen condition:
If(Result1 > 10, "Success", "Fail")
The Else value, like Precision is Optional and if you skip it and the condition is not satisfied no value will be assigned to field:
If(Result1 > 10, "Success")
Error checking
The formula editor has additional check settings so if you entered wrong expression - not existing field/option/function, mistakes in function structure you will not be allowed to save the expression:
The provided expression(CONTAIN(Technician,Abbott, Claude)) looks legit : The function Contain exists, the field Technician also, there is Technician Abbott, Claude, but since it's an option and an option must be in "" it's not a valid expression and the error message will appear. If we add the "" then we'll be able to save it and we will see this window:
, which means that the expression is legit and we can Save the field. If we don't press Save, although the expression is added it won't be saved!
At any point you can go click Edit and change the expression. If you want to remove it click Clear button and again Save.