Operators and Precedence

  • Last update:December 13, 2024
  • Overview

    An operator is used to specify the type of calculation to be performed on the elements in a formula. You can use the default calculation order or change the order using parentheses.

    Operator Type

    Four types of calculation operators are available: arithmetic operator, comparison operator, logical operator, and string concatenation operator.

    Arithmetic Operator

    You can use the following arithmetic operators in formulas to perform basic mathematical operations such as addition, subtraction, multiplication, and division.

    Arithmetic Operator
    ExampleResult

    + (addition operator)

    = 3 + 3

    6

    – (subtraction operator/unary minus operator)

    = 3 – 1

    2

    * (multiplication operator)

    = 3 * 3

    9

    / (division operator)

    = 15/3

    5

    % (remainder operator)

    = 20 % 6

    2

    ^ (exponentiation operator)

    = 3 ^ 2

    9

    Comparison Operator

    You can use the following operators to compare two values. When you use these operators to compare two values, the result is a logical value: TRUE or FALSE.

    Comparison Operator
    DefinitionExample

    = (equality operator)

    Equal to

    A1 = B1

    > (greater than operator)

    Greater than

    A1 > B1

    < (less than operator)

    Less than

    A1 < B1

    > = (greater than or equal operator)

    Greater than or equal to

    A1 > = B1

    < = (less than or equal operator)

    Less than or equal to

    A1 < = B1

    != (inequality operator) 

    iconNote:
    The operator is different from the <> operator in Excel.

    Not equal to

    A1 != B1

    Logical Operator

    The usage of logical operators is the same as that of the AND and OR functions.

    Logical OperatorDefinitionExample

    &&

    Logical AND, which returns true if both expressions are true.

    Sales > = 10 && Number of salespeople > = 2

    ||

    Logical OR, which returns true if one of the expressions is true.

    Sales > = 10 || Number of salespeople > = 2

    iconNote:
    A logical operator can only connect two expressions of boolean or numeric types.

    String Concatenation Operator

    You can use the + operator to concatenate text fields.

    For example, you can use the CONCATENATE function to concatenate the text fields Store Style and Store Name. You can also simply use the + operator, as shown in the following figure.

    1.png

    2.png

    Formula Calculation Order

    In some cases, the calculation order may affect the returned value of a formula. Therefore, you need to know how to determine the order and how to change the order to obtain the desired result.

    Operator Precedence

    If a formula contains multiple operators, the calculation will be performed according to the operator precedence (shown in the following table) in FineBI. If multiple operators in a formula have same level of precedence (for example, a formula contains both a multiplication operator and a division operator), the calculation will be performed according to the following associativity in FineBI.

    Precedence

    Operator

    Definition

    Usage

    Associativity

    1

    Unary minus operator

    Expression

    Right to left

    2

    ^

    Exponentiation operator

    Expression ^  Expression

    Left to right

    3

    *

    Multiplication operator

    Expression *  Expression

    /

    Division operator

    Expression/Expression

    %

    Remainder operator

    Expression % Expression

    4

    +

    Addition operator

    Expression + Expression

    Subtraction operator

    Expression Expression

    5

    Greater than operator

    Expression > Expression

    Less than operator

    Expression < Expression

    > =

    Greater than or equal operator

    Expression > = Expression

    < =

    Less than or equal   operator

    Expression < = Expression

    6

    =, ==

    Equality operator

    Expression = Expression

    Expression == Expression

    !=

    Inequality operator

    Expression != Expression

    7

    &&

    Logical AND

    Expression && Expression

    8

    ||

    Logical OR

    Expression || Expression

    Calculation with Parentheses

    To change the calculation order, you need to enclose the part that needs to be calculated first in parentheses.

    For example, the result of the following formula is 11, because multiplication is calculated before addition. The formula first multiplies 2 by 3, and then adds 1 and 4 to the result.

    = 1 + 2 * 3 + 4

    However, if you use parentheses to modify the syntax as follows, 1 and 2 will be added together first, and the result (3) will be multiplied by 3. Finally, 4 will be added to the product to get 13.

    = (1 + 2) * 3 + 4

    附件列表


    主题: Advanced Data Analysis
    Previous
    Next
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy