Tableau provides various Math and Trigonometric Functions to perform mathematical operations on our data. They are FLOOR, CEILING, ABS, DIV, POWER, SQRT, SQUARE, MIN, MAX, SIN, COS, TAN, ACOS, ASIN, ATAN, ATAN2, LN, LOG, etc. In this article, we show how to use Tableau Math Functions with examples.
To demonstrate these Tableau Math Functions, we are going to use the data shown below. As you can see, there are nine records in this table.
Remember, this is an Excel Worksheet. So, Please refer to the Connecting to the Excel Files article to understand the connection settings.
Tableau Math Functions
The following examples will show you the list of Math Functions in Tableau
ABS
The Tableau ABS math function is used to return the absolute positive value, and the syntax of this ABS is:
ABS(number)
To demonstrate these math functions, we use Calculated Fields. To create a calculated field, navigate to the Analysis Tab, and select the Create Calculated Field… option.
Once you click on the Create Calculated Field… option, the following window will open. Here, we renamed the default calculation name as ABS.
The below statement will find the Absolute values of the Service Grade.
ABS([Service Grade])
Let me add this ABS field to an existing table (by dragging a field to Measures Shelf). Please refer Create Table Report article to understand the process of creating a table
Tableau ACOS function
The Tableau ACOS function calculates the Arc cosine of a given number, and the syntax of this ACOS is:
ACOS(Number)
The below ACOS statement will find the ArcCosine of Service Grade
ACOS([Service Grade])
ASIN
Tableau ASIN function will calculate the Arc sine of a given number, and the syntax of this ASIN is:
ASIN(Number)
The following statement finds the Arcsine of Service Grade
ASIN([Service Grade])
ATAN
Tableau ATAN function is used to calculate the Arc Tangent of a given number, and the syntax of this ATAN is:
ATAN(Number)
Below statement will find the Arc Tangent of Service Grade
ATAN([Service Grade])
Tableau SIN Function
Tableau SIN function is used to calculate the Sine value, and the syntax of this SIN is:
SIN(Number)
It will find the Sine value of the Service Grade
SIN([Service Grade])
TAN
Tableau TAN function is to calculate the Tangent value, and the syntax of this TAN is:
TAN(Number)
The below statement will find the Tangent value of Service Grade
TAN([Service Grade])
Let me add this TAN field to the Measures shelf
COS
Tableau COS function will calculate the Cosine value, and the syntax of this COS is:
COS(Number)
It will find the Cosine value of the Service Grade
COS([Service Grade])
ATAN2
Tableau ATAN2 function is to calculate the arc Tangent of two given numbers, and the syntax of this ATAN2 is:
ATAN2(y_number, x_number)
The below statement will find the Arc Tangent value of the Sales amount and Standard cost.
ATAN2([Standard Cost], [Sales Amount])
COT
Tableau COT math function will calculate the Cotangent value, and the syntax of this COT is:
COT(Number)
It will find the Cotangent value of Service Grade
COT([Service Grade])
Tableau DEGREES Function
The Tableau math Degrees function will convert Radians to Degrees, and the syntax of this Degrees is:
DEGREES(Number)
It will convert the Radiant value in Service Grade to degrees
DEGREES([Service Grade])
Let me add this Degrees field to the Measures shelf
Tableau RADIANS Function
The Tableau RADIANS math function will convert Degrees to Radians, and the syntax of this Radians is:
RADIANS(Number)
It will convert the value of the degree in Sales Amount to Radians.
RADIANS([Service Grade])
Let me add this Radians field to the Measures shelf
Tableau EXP Function
The EXP function returns e raised to the power of the user-specified number, and the syntax of this EXP is:
EXP(Number)
It finds e power service grade
EXP([Service Grade])
Let me add this EXP field to the Measures shelf.
Tableau math SQUARE Function
The Tableau Square function finds the square of a given number, and the syntax of this math Square Function is:
SQUARE(Number)
It will find out the square of the tax amount
SQUARE([Tax Amt])
Let me add this SQUARE field to the Measures shelf.
Tableau SQRT Function
The Tableau Sqrt function finds the square root of a given number, and the syntax of this math Sqrt is:
SQRT(Number)
It will find the square root of the Sales amount
SQRT([Sales Amount])
Let me add this SQRT field to the Measures shelf
Tableau ROUND Function
The Tableau math Round function returns the nearest integer value. It accepts the second argument (optional) to specify the number of decimals. The syntax of this Round Function is:
ROUND(Number, no_of_decimals)
For example,
- ROUND(248.6759) = 249
- ROUND(248.6759, 1 ) = 248.7
- ROUND(248.6759, 2 ) = 248.68
The below statement will round the Standard Cost values to the nearest integer
ROUND([Standard Cost])
Let me add this ROUND field to the Measures shelf
Tableau math CEILING Function
The Tableau Ceiling function returns the closest integer value, which is greater than or equal to a given value. The syntax of this Ceiling Function is:
CEILING(Number)
The below statement will find the closest integer value that is greater than or equal to the Standard Cost
CEILING([Standard Cost])
Let me add this CEILING field to the Measures shelf
Tableau FLOOR Function
The Tableau math Floor function is used to return the closest integer value, which is less than or equal to a given value. The syntax of this Floor Function is:
FLOOR(Number)
The below Floor statement will find the closest integer value that is less than or equal to the Standard Cost
FLOOR([Standard Cost])
Tableau SIGN Function
The Sign function is handy for finding the integer Sign. This function returns
- +1 = Positive Value
- -1 = Negative values
- 0 = for zeros.
The syntax of this Tableau Sign Function is:
SIGN(Number)
The Sign function will find the sign of a Service Grade records
SIGN([Service Grade])
Tableau PI Function
The PI returns a numeric value of 3.14, and the syntax is:
PI()
It will divide the PI value, i.e., 3.14, with Service Grade values. Let me add this PI field to the Measures shelf
PI() / [Service Grade]
Tableau POWER Function
This function is used to find the Power of a given number. Use the second argument to specify the Power. The syntax of this Tableau math Power Function is:
POWER(Number, power)
For example Power(2, 3) = 2³. It will find the Sales Amount raised to the power of 2
POWER([Sales Amount], 2)
Let me add this Power field to the Measures shelf
LN
The Tableau LN function is used to find the natural logarithmic value of a given number, and the syntax of this LN is:
LN(Number)
It will find the natural logarithmic value of Sales Amount
LN([Sales Amount])
LOG
The Tableau LOG function is used to find the logarithmic value of a given number for a specified base. Here, the second argument is optional, and its default value is 10. The syntax of this LOG is:
LOG(Number, base)
It will find the logarithmic value of Sales Amount for base 5
LOG([Sales Amount], 5)
Let me add this LOG field to the Measures shelf
DIV
The Tableau DIV function divides one number by another, and the syntax of this DIV is:
DIV(integer, integer)
The following DIV statement divides the Sales Amount by 5
DIV(INT([Sales Amount]), 5)