Skip to content

Operators

HENGSHI SENSE allows the use of operators to create expressions for comparing values or performing arithmetic calculations. There are three different types of calculation operators: arithmetic, comparison, and logical.

Arithmetic Operators

Arithmetic OperatorMeaningExample
+ (Plus)Addition3 + 3 = 6
+? (Non-null Plus)Treats null as 0 during addition3 +? null = 3
- (Minus)Subtraction or Negative Sign3 - 1 - 1 = 1
-? (Non-null Minus)Treats null as 0 during subtraction3 -? null -? 1 = 2
* (Asterisk)Multiplication3 * 3 = 9
/ (Forward Slash)Division3 / 3 = 1
% (Percent Sign)Modulus (Remainder)16 % 5 = 1
^ (Caret)Exponentiation16 ^ 4 = 65536

Comparison Operators

Comparison OperatorMeaningExample
=Equal to{Region} = 'cn'
!=Not equal to{Region} != 'cn'
>Greater than{Sales Date} > '2009-01-01'
<Less than{Sales Date} < '2009-01-01'
>=Greater than or equal to{Amount} >= 20000
<=Less than or equal to{Amount} <= 100
<>Not equal to{Region} <> 'cn'
inIn a set{Region} in ('cn','us')
notinNot in a set{Region} not in ('cn','us')

Logical Operators

Logical OperatorMeaningExample
andCreates an AND condition between two expressions, where each expression has a Boolean result. If both expressions return TRUE, the combined expression also returns TRUE; otherwise, the combination returns FALSE.({Region} = 'cn') and ({status} = 1))
orCreates an OR condition between two logical expressions. If either expression returns TRUE, the result is TRUE; the result is FALSE only when both expressions are FALSE.(([Region] = "France") or {status} = 1
notNegates the Boolean value of a logical expression.not ({status} = 1)

Operator Precedence

If multiple operators are combined in a single formula, they are sorted according to the table below. If the precedence values of the operators are equal, they are sorted from left to right. Parentheses can be used to adjust the calculation order, with the calculations inside parentheses having the highest precedence.
For example, if an expression contains both multiplication and division operators, they are calculated in the order they appear from left to right in the expression. The operator precedence in the table below is arranged from highest to lowest.

OperatorDescription
^Exponentiation
Sign (e.g., –1)
* , /, %Multiplication, Division, Modulus
+, +?, –, -?Addition, Non-null Addition, Subtraction, Non-null Subtraction
=, !=, <, >, <=, >=, <>Comparison
in, notinMembership in a set
notLogical NOT
andLogical AND
orLogical OR

Example: Combination of and and or expressions

5 > 6 or 5 < 3 and 5 = 5

Calculation steps:

  • 5 > 6, returns false
  • 5 < 3, returns false; 5 = 5, returns true; Logical AND, returns false
  • Logical OR, returns false

User Manual for Hengshi Analysis Platform