Tableau Operators

An operator is a symbol for performing specific mathematical and logical operations through the compiler.

Tableau has several numbers of operators which are used to create calculated fields and formulas.

Here are the types of operators with their order of precedence of operation:

Types of operators

  1. General operators
  2. Arithmetic operators
  3. Relational operators
  4. Logical operators

1. General Operators

Here are some general operators supported by Tableau. These operators act on the character, numeric, and date data type.

  • Addition (+): By the help of the addition operator, we can add the two numbers, concatenate two strings and also add days to dates.
    Example: 10+15=25
                     Sales+ profit
                     'XYZ'+ 'PQR'= XYZPQR
                     # June 8, 2018 # + 7= # June 15, 2018 #
  • Subtraction (-): By the help of the subtraction operators, we can subtract two numbers and subtract days from dates.
    Example: - (10+15) = -25
                      # June 8, 2018 # - 7= # June 1, 2018 #

2. Arithmetic Operators

Here are some arithmetic operators supported by Tableau. All these operators act only on the numeric data type.

  • Multiplication (*): we can multiply two numbers by the help of multiplication operator.
    Example: 5 * 2 = 10
  • Division (/): we can divide two numbers by the help of the division operator.
    Example: 15 / 5 = 3
  • Modulo (%): modulo operator gives you the remainder of the numeric division.
    Example: 17 % 2 = 1
  • Power (^): raised to the power.
    Example: 2 ^ 2 = 4

3. Relational Operators

Here are the relational operators supported by Tableau. These operators are used in the expressions. Each relational operator compares two numbers, strings, or dates and returns a Boolean value (True or False).

However, Boolean operators themselves cannot be compared using these operators.

  • Equal to (= or = =): It compares two numbers, strings or two dates to be similar and returns the Boolean values, true if they are equal else returns False.
    Example: 'hello' = 'hello', returns True
                      '2' = '10/5', returns True
                      'Hello' = 'hey', returns False
  • Not equal to (! = or <>): It compares two numbers, two strings, or dates to be unequal. And returns the Boolean values, true if they are equal else returns False.
    Example: 'cold' <> 'hot'
                      '13' != '24/2'
  • Greater than (>): It compares two numbers, two strings or two dates where the first argument is greater than second, it Returns the Boolean value True else returns False.
    Example: [Profit] > 10000
                      [Category] > 'Q'
                      [Ship date] > #April 1, 2018#
  • Less than (<): It compares two numbers, two strings or two dates, where the first argument is smaller than the second. It returns the Boolean value True, else returns false.
    Example: [Profit] < 10000
                      [Category] < 'Q'
                      [Ship date] < #April 1, 2018#

4. Logical operators

Here are the logical operators supported by Tableau. These operators are used in an expression whose result is a Boolean value (True or False).

  • AND: If the Boolean values present on both sides of AND operator is evaluated to be TRUE, then the result is TRUE. Else the result is FALSE.
    Example: [Ship Date] > #April 1, 2018# AND [Profit] > 20000
  • OR: If anyone or both of the Boolean values present on both sides of the OR operator analyses to be TRUE, then the result is TRUE. Else the result is FALSE.
    Example: [Ship Date] > #April 1, 2018# OR [Profit] > 20000
  • NOT: This operator reverses the Boolean value of the expression.
    Example: NOT [Ship Date] > #April 1, 2018#

Precedence of Operator

The below table is describing the order of precedence of the operator. The top row of below table has the highest precedence. Some operators in the same row have the same precedence.

If two operators have the same precedence, they are analyzed from left to the right in the formula. Parentheses can also be used in the same order, and the inner parentheses are evaluated before the outer parentheses.

Order of PrecedenceOperators
1-(negate)
2^(power)
3*, /, %
4+, -
5==, >, <, >=, <=, !=
6NOT
7AND
8OR





Latest Courses