# Operators

Operators specify the type of calculation that you want to perform on the elements of a formula. There is a default order in which calculations occur (this follows general mathematical rules), but you can change this order by using parentheses.

**Types of operators**

There are four different types of calculation operators: arithmetic, comparison, text concatenation, and reference.

**Arithmetic operators**

To perform basic mathematical operations, such as addition, subtraction, multiplication, or division; combine numbers; and produce numeric results, use the following arithmetic operators.

Arithmetic Operator | Meaning | Example |
---|---|---|

Addition | 3+3 | |

Subtraction | 3-1 | |

Multiplication | 3*3 | |

/ | Division | 3/3 |

^ | Pow | 2^8 |

**Comparison operators**

You can compare two values with the following operators. When two values are compared by using these operators, the result is a logical value—either TRUE or FALSE.

Comparison operator | Meaning | Example |
---|---|---|

= | Equal to | [Field 1]=[Field 2] |

Greater than | [Field 1]>[Field 2] | |

< | Less than | [Field 1]<[Field 2] |

/>= | Greater than or equal to | [Field 1]>=[Field 2] |

<= | Less then or equal to | [Field 1]<=[Field 2] |

<> | Not equal to | [Field 1]<>[Field 2] |

**Text concatenation operator**

Use the ampersand (&) to concatenate (join) one or more text strings to produce a single piece of text.

Text operator | Meaning | Example |
---|---|---|

& | Connects, or concatenates, two values to produce one continuous text value | "North" & "wind" results in "Northwind" |

**Reference operators**

Combine ranges of cells for calculations with the following operators.

Reference operator | Meaning | Example |
---|---|---|

: | Range operator, which produces one reference to all the table rows/columns between two references, including the two references. | [1][1]:[1][15] |

, | Union operator, which combines multiple references into one reference | SUM([1][1]:[1][15],[4][1]:[4][15]) |

**The order in which GoFormz performs operations in formulas**

In some cases, the order in which a calculation is performed can affect the return value of the formula, so it's important to understand how the order is determined and how you can change the order to obtain the results you want.

**Calculation order**

Formulas calculate values in a specific order. A formula in GoFormz always begins with an equal sign (=). GoFormz interprets the characters that follow the equal sign as a formula. Following the equal sign are the elements to be calculated (the operands), such as constants or field references. These are separated by calculation operators. GoFormz calculates the formula from left to right, according to a specific order for each operator in the formula.

**Operator precedence in GoFormz formulas**

If you combine several operators in a single formula, GoFormz performs the operations in the order shown in the following table. If a formula contains operators with the same precedence (for example, if a formula contains both a multiplication and division operator), GoFormz evaluates the operators from left to right.

Operator | Description |
---|---|

: and , | Reference operators |

* and / | Multiplication and division |

+ and - | Addition and subtraction |

& | Connects two strings of text (concatenation) |

= | Comparison |

**Use of parentheses in GoFormz formulas**

To change the order of evaluation, enclose in parentheses the part of the formula to be calculated first. For example, the following formula produces 11 because GoFormz performs multiplication before addition. The formula multiplies 2 by 3 and then adds 5 to the result.

`=5+2*3`

In contrast, if you use parentheses to change the syntax, GoFormz adds 5 and 2 together and then multiplies the result by 3 to produce 21.

`=(5+2)*3`

In the following example, the parentheses that enclose the first part of the formula force GoFormz to calculate [Field 1]+25 first and then divide the result by the sum of the values in the first 3 rows of the first column of a table.

`=([Field 1]+25)/SUM([Table]![1][1]:[1][3])`

Updated 9 months ago