Tap Forms has a special field type called Calculation.

For basic math, use the following operators:

Operator | Symbol |
---|---|

Add | `+` |

Subtract | `-` |

Multiply | `*` |

Divide | `/` |

Logical AND | `&` |

Logical OR | `~` |

The following mathematical expressions in the Calculation field formula editor are supported:

### Single parameter functions:

**ABS**: absolute value, which can be used as `ABS(X)`

**ATAN**: ArcTangent function which can be used as `ATAN(X)`

**CEIL**: `CEIL(-3.2) = 3`

, `CEIL(3.2) = 4`

**COS**: Cosinus function which can be used as `COS(X)`

, X is a real-type expression. COS returns the cosine of the angle X in radians.**COSH**: Cosinus Hyperbolic function which can be used as `COSH(X)`

**COTAN**: which can be used as `COTAN(X)`

**EXP**: which can be used as `EXP(X)`

**FLOOR**: `FLOOR(-3.2) = -4`

, `FLOOR(3.2) = 3`

**LN**: natural log, which can be used as `LN(X)`

**LOG**: 10 based log, which can be used as `LOG(X)`

**NOW**: inserts the current time in seconds since January 1, 1970 00:00:00 GMT**SIGN**: `SIGN(X)`

returns -1 if X<0; +1 if X>0, 0 if X=0; it can be used as `SQR(X)`

**SIN**: Sinus function which can be used as `SIN(X)`

, X is a real-type expression. Sin returns the sine of the angle X in radians.**SINH**: Sinus Hyperbolic function which can be used as `SINH(X)`

**SQR**: Square function which can be used as `SQR(X)`

**SQRT**: which can be used as `SQRT(X)`

**TAN**: which can be used as `TAN(X)`

**TRUNC**: Discards the fractional part of a number. e.g. `TRUNC(-3.2)`

is -3, `TRUNC(3.2)`

is 3.

### Two parameter functions:

**INTPOW**: The `INTPOW`

function raises Base to an integral power. `INTPOW(2, 3) = 8`

. Note that result of `INTPOW(2, 3.4) = 8`

as well.**POW**: The Power function raises Base to any power. For fractional exponents or exponents greater than MaxInt, Base must be greater than 0.**LOGN**: The `LogN`

function returns the log base N of X. Example: `LOGN(10, 100) = 2`

**MIN**: `MIN(2, 3)`

is 2.**MAX**: `MAX(2, 3)`

is 3.**DATE**: The `DATE([Field], "yyyy-MM-dd")`

function formats a date in a human readable way. Please see the Unicode Technical Standard #35 for pattern syntax and examples.**FORMAT**: The `FORMAT([Field], "#.00")`

function formats a number in a variety of ways and returns a text representation of the number. Please see the Unicode Technical Standard #35 for pattern syntax and examples.

### Three parameter functions:

**IF**: The `IF(b, case1, case2)`

function provides branching capability. If b is not 0, then it returns case1, else it returns case2. Example: `IF(HEIGHT, 3/HEIGHT, 3)`

will make sure 3/HEIGHT does not cause a division by zero error.**IFEMPTY**: The `IFEMPTY([Field], case1, case2)`

function also provides branching capability. If [Field] is empty, then it returns case1, else it returns case2.**IFNOTEMPTY**: The `IFNOTEMPTY([Field], case1, case2)`

function also provides branching capability. If [Field] is NOT empty, then it returns case1, else it returns case2.

### No parameter functions:

**NOW**: `NOW()`

inserts the current date and time in seconds into the formula.**TODAY**: `TODAY()`

inserts the current date in seconds into the formula. The time is 00:00:00.**RND**: `RND()`

function generates a random number `(double value)`

between 0 and 1.

### Multiple parameter functions:

**AVG**: `AVG(2, 5, 3,...)`

returns the average of all the parameters. e.g. AVG is 3.5.**SUM**: `SUM(2,3,5,…)`

functions returns the sum of it’s arguments. There is no preset limit on the number of parameters.**CONCAT**: `CONCAT("A", "B", "C",...)`

joins values together. It’s an alternative to the `+`

function for text concatenation.

### Text Concatenation

In addition to the above mathematical expressions, Tap Forms also supports text concatenation. With this feature, you can create Calculation fields which return a Text value instead of a Number value.

For example, you could create a Calculation field called **Full Name** (or whatever you want to call it) which has the following formula:

`First Name`

+ “ “ + `Last Name`

As long as you set the **Result Type** property on the Formula Editor to **Text**, then Tap Forms will evaluate the above formula and return the string with the First Name and Last Name fields joined together with a space character in between. It’s especially useful for creating labels. You can keep your First Name and Last Name fields as separate fields, but for printing labels, you would want them to be joined together into a Full Name field to make your labels look nicer.

An example of joining the parts of a mailing address so it avoids blank lines if certain fields are empty:

`First Name`

+ “ “ + `Last Name`

+ “\r” +**IFNOTEMPTY (** `Company`

, `Company`

+ “\r”, “” **)** +`Address 1`

+ “\r” +**IFNOTEMPTY (** `Address 2`

, `Address 2`

+ “\r”, “” **)** +`City`

+ “, “ + `Province`

+ “ “ + `Postal Code`

In the above example, the **IFNOTEMPTY (** `Company`

, `Company`

+ “\r”, “” **)** part checks to see if the `Company`

field is not empty. If it has a value, it returns the value in the `Company`

field and adds a linefeed character to it. If it has no value, it simply returns nothing (an empty string).

The `"\r"`

part inserts a new line into the result.

Need more help with this?

Don’t hesitate to contact us here.