May 26, 2021 Tableau
An operator is a symbol that tells the compiler to perform specific mathematical or logical operations. /b10> Tableau has several operators for creating calculated fields and formulas.
The details of the available operators and the order (priority) of the operations are as follows:
The following table shows the general operators supported by Tableau. /b10> These operators work on numbers, characters, and date data types.
Operator | Describe | Example |
---|---|---|
+(addition) |
It adds two numbers.
It connects two strings. It increases the number of days of dates. |
7 + 3
Profit and sales \'abc\'+\'def\'=\'abcdef\' #April 15,2004#+ 15 = #April 30,2004# |
–(subtraction) |
I subtract two numbers.
It subtracts the number of days from the date. |
- (7 + 3)= -10
#April 16,2004# - 15 = #April 1,2004# |
The following table shows the arithmetic operators supported by Tableau. /b10> These operators only work on numeric data types.
Operator | Describe | Example |
---|---|---|
*(Multiplication) | Multiplication | 23 * 2 = 46 |
/(Division) | Division | 45/2 = 22.5 |
%(modulo) | Find the remaining number | 13%2 = 1 |
^(power) | Ask for a few square roots | 2 ^ 3 = 8 |
The following table shows the comparison operators supported by Tableau. /b10> These operators are used for expressions. /b11> Each operator compares two numbers, a date, or string, and returns a Boolean value (TRUE or FALSE). /b12> However, Boolean itself cannot use these operators for comparison.
Operator | Describe | Example |
---|---|---|
2 ^ 3 = 8 ... | Compare two numbers or two strings or two dates equal. /b10> Return the Boolean value TRUE if they return false. |
\'Hello\'=\'Hello\'
2 ^ 3 = 8 |
! or (not equal to) | Compare two numbers or two strings or two dates that are not equal. /b10> Return the Boolean value TRUE if they return false. |
'Good', 'Bad'
18! = 37/2 |
> (Greater than) | Compare two numbers or two strings or two dates, where the first argument is greater than seconds. /b10> If else returns false, the Boolean value TRUE is returned. |
(Profits)
20000
[Category]> \'Q\' (Shipping date) . #April |
slt;(less than) | Compare two numbers or two strings or two dates, where the first argument is less than seconds. /b10> If else returns false, the Boolean value TRUE is returned. |
(Profit)
slt;20000
(Category) slt;"Q" (Ship Date) slt;#April 1, 2004 # |
The following table shows the logical operators supported by Tableau. /b10> These operators are used for expressions whose result is Boolean values, giving an output of TRUE or FALSE.
Operator | Describe | Example |
---|---|---|
AND | True if the expression or boolean value that exists on both sides of the AND operator is evaluated as TRUE. /b10> Otherwise, the result is FALSE. | (Ship Date) #April 1,2012 .AND (Profit) .10000 |
OR | If any one or two expressions or boolean values that exist on either side of the AND operator are evaluated as TRUE, the result is TRUE. /b10> Otherwise, the result is FALSE. | (Shipping Date) #April 1, 2012 |
NOT | This operator negates the Boolean value of the expression that follows. | NOT [Ship Date]> #April 1,2012# |
The following table describes the order of the characters. /b10> The top row has the highest priority. /b11> Operators on the same line have the same priority. /b12> If two operators have the same priority, they are measured from left to right in the formula. /b13> You can also use parentheses. /b14> The inner parenthesis is measured before the outer parenthesis.
Priority | Operator |
---|---|
1 | –(negate) |
2 | ^(power) |
3 | *,/,% |
4 | +, - |
5 | ==,>,=, |