1. Overview
Operator is used to specify the type of calculation to perform on the elements in the formula. There is a default calculation order, but you can change this order using parentheses.
2. Operator type
There are four different types of evaluation operators: arithmetic, comparison, logic, and string splicing.
2.1 Arithmetic operator
Perform basic mathematical operations, such as addition, subtraction, multiplication, division, etc., and use the following arithmetic operators in the formula:
Arithmetic operator | Example | Result |
---|---|---|
+(Plus) | = 3 + 3 | 6 |
-(Minus) | = 3 - 1 | 2 |
*(Multiply) | = 3 * 3 | 9 |
/(Divide) | = 15 / 3 | 5 |
%(Remainder) | = 20 % 6 | 2 |
^(Power) | = 3 ^ 2 | 9 |
2.2 Comparison operator
You can compare two values using the following operators. When these operators are used to compare two values, the result is a logical value of "TRUE" or "FALSE".
Comparison operator | Meaning | Example |
---|---|---|
=(Equal sign) | A1 = B1 | |
>(Greater than sign) | Greater than | A1 > B1 |
<(Smaller than sign) | Less than | A1 < B1 |
>=(Greater than or equal to sign) | Greater than or equal to | A1 >= B1 |
<=(Less ) | Less | A1 <= B1 |
!=(Unequal sign)Note: it is different from < > in Excel. | Unequal to | A1 != B1 |
2.3 Logical operator
Logical operators are used in the same way as "AND" and "OR".
Logical operator | Meaning | Example |
---|---|---|
&& | Logical and, satisfying multiple expression conditions at the same time | Sales volume>=10&&Sales person>=2 |
|| | Logical or, as long as one of multiple expression conditions is satisfied | Sales volume>=10||Sales person>=2 |
Note: logical operators can only connect two boolean or numeric expressions.
2.4 String splicing operator
text fields。
For example, the text fields "store style" and "store name" can be spliced together. Of course, the CONCATENATE indicator can be used, but a simpler scheme is to directly use "+", as shown in the following figure:
3. Order of formula operation
In some cases, the order in which calculations are performed may affect the return value of the formula, so you must know how to determine the order and how to change the order to obtain the desired results.
3.1 Operator priority
If there are several operators in a formula, FineBI will calculate in the order in the following table. If several operators in a formula have the same priority (for example, if a formula has both a multiplication sign and a division sign), finebi will calculate the operators in the following direction.
Priority | Operator | Meaning | Usage | Combination direction |
---|---|---|---|---|
1 | - | Minus | -Para | From right to left |
2 | ^ | Power | Para^Para | From left to right |
3 | * | Para*Para | ||
/ | Para/Para | |||
% | Para%Para | |||
4 | + | Para+Para | ||
- | Minus | Para-Para | ||
5 | > | Para>Para | ||
< | Less than | Para<Para | ||
>= | Para>=Para | |||
<= | Para<=Para | |||
6 | =、== | Equal to | Para=Para Para==Para | |
!= | Unequal to | Para!=Para | ||
7 | && | Para&&Para | ||
8 | || | Para||Para |
3.2 Calculation method using parentheses
To change the calculation order, you need to enclose the part of the formula to be calculated first in parentheses.
For example, the following formula generates 11 because multiplication is calculated before addition. The formula first multiplies 2 and 3, and then adds 1 and 4 to the result.
=1+2*3+4
However, if you change the syntax with parentheses, you add 1 and 2 together, then multiply the result by 3, and then add 4 to get 13.
=(1+2)*3+4