Calculation operator and priority

  • Last update:  2022-04-08
  • 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
    ExampleResult
    +(Plus)= 3 + 36
    -(Minus)= 3 - 12

    *(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
    MeaningExample

    =(Equal sign)

    Equal

    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 than or equal to sign

    Less than or equal to

    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 operatorMeaningExample
    &&

    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 satisfiedSales volume>=10||Sales person>=2

    Note: logical operators can only connect two boolean or numeric expressions.

    2.4 String splicing operator

    You can use the "+" operator to merge 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.

    PriorityOperatorMeaningUsageCombination direction
    1

    -

    Minus

    -Para

    From right to left

    2^PowerPara^Para

    From left to right

    3*

    Multiply

    Para*Para
    /

    Divide

    Para/Para
    %

    Remainder

    Para%Para
    4+

    Plus

    Para+Para
    -MinusPara-Para
    5>

    Greater than

    Para>Para
    <Less thanPara<Para
    >=

    Greater than or equal to

    Para>=Para
    <=

    Less than or equal to

    Para<=Para
    6=、==Equal to

    Para=Para

    Para==Para

    !=Unequal toPara!=Para
    7&&

    Logical AND

    Para&&Para
    8||

    Logical OR

    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



    附件列表


    主题: 隐藏by Chauvet
    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