[]
        
(Showing Draft Content)

Operators

The analytical expressions make use of operators for creating expressions to compare values, perform arithmetic calculations, or also work with strings.

Types of Operators

There are four types of calculation operators available: arithmetic, comparison, text concatenation, and logical.

Arithmetic Operators

Use the following arithmetic operators to perform basic mathematical operations such as addition, subtraction, or multiplication; combine numbers; or produce numeric results.

Operator Description Example
+ (plus sign) Addition 1 + 1
– (minus sign) Subtraction 6 – 4 – 1
* (asterisk) Multiplication 5 * 4
/ (forward slash) Division 3 / 3
^ (caret) Exponentiation 81 ^ 4

Note:
1. The plus sign (+) and the minus sign (-) can both serve as a binary operator and as a unary operator.
2. The forward slash is an unsafe division. Please use the divide function for using a safe division. For more information, see Math functions article.

Comparison Operators

You can use the following operators to compare two values. While comparing two values by using the following operators, the result is always a logical value, either TRUE or FALSE.

Operator Description Example
= Equal to [Region] = "China"
== Strict equal to [Region] == "China"
> Greater than [SaleAmount] > 10000
< Less than [SaleAmount] < 10000
>= Greater than or equal to [Amount] >= 2000
<= Less than or equal to [Amount] <= 10
<> Not equal to [Region] <> "USA"

Note: The settings of the database itself specify whether the "=" operator is case-sensitive or not.

Text concatenation operator

Use the ampersand (&) to join or concatenate two or more text strings for creating a single piece of text.

Operator Description Example
& (ampersand) Connects, or concatenates, two values to produce one continuous text value [City] & ", " & [Street]

Logical operators

Use logical operators (&&) and (||) to combine expressions for creating a single result.

Operator Description Example
&& (double ampersand) Creates an AND condition between the two expressions and each has a Boolean result. If both the expressions return TRUE, then combination of the expressions will also return TRUE; otherwise, the combination returns FALSE. ([City] = "Beijing") && ([Color] = "Red"))
|| (double pipe symbol) Creates an OR condition between two logical expressions. If either of the expression return TRUE, then the result is TRUE. Only when both expressions are FALSE, then the result is also FALSE. ([City] = "Beijing") || ([Color] = "Red"))
IN Creates a logical OR condition between each row being compared to a table. The table constructor syntax uses curly braces. IN ('Product'[Color] , "Red", "Blue", "Black")

Note: The "IN" operator mentioned above is a function, not a binary operator.

Operator Precedence

If you combine multiple operators within a single formula, the operations are ordered according to the following table. In case the operators have equal precedence values, they are ordered from left to right. For example, if an expression contains both a multiplication and a division operator, they are evaluated in the order in which they appear in the expression, that is, from left to right.

Operator Description
^ Exponentiation
Sign (as in –1)
* and / Multiplication and division
+ and – Addition and subtraction
& Connects two strings of text (concatenation)
=,==,<,>,<=,>=,<>,IN Comparison
NOT NOT (unary operator)