This article introduces number functions and their uses in Tableau. It also demonstrates how to create a number calculation using an example.
Why use number functions
Number functions allow you to perform computations on the data values in your fields. Number functions can only be used with fields that contain numerical values. For more information, see Data Types.
For example, you might have a field that contains values for the variance in your budget, titled Budget Variance. One of those values might be -7. You can use the ABS function to return the absolute value of that number, and all the other numbers in that field.
The calculation might look something like this:
Therefore, ABS(-7) = 7.
Number functions available in Tableau
Returns the absolute value of the given number.
The second example returns the absolute value for all the numbers contained in the
Returns the arc cosine of the given number. The result is in radians.
Returns the arc sine of a given number. The result is in radians.
Returns the arc tangent of a given number. The result is in radians.
Returns the arc tangent of two given numbers (x and y). The result is in radians.
Returns the cosine of an angle. Specify the angle in radians.
Returns the cotangent of an angle. Specify the angle in radians.
Converts a given number in radians to degrees.
Returns the integer part of a division operation, in which integer1 is divided by integer2.
Returns e raised to the power of the given number.
Maps an x, y coordinate to the x-coordinate of the nearest hexagonal bin. The bins have side length 1, so the inputs may need to be scaled appropriately.
HEXBINX and HEXBINY are binning and plotting functions for hexagonal bins. Hexagonal bins are an efficient and elegant option for visualising data in an x/y plane such as a map. Because the bins are hexagonal, each bin closely approximates a circle and minimises variation in the distance from the data point to the centre of the bin. This makes the clustering both more accurate and informative.
Maps an x, y coordinate to the y-coordinate of the nearest hexagonal bin. The bins have side length 1, so the inputs may need to be scaled appropriately.
Returns the natural logarithm of a number. Returns
Returns the logarithm of a number for the given base. If the base value is omitted, base 10 is used.
Returns the maximum of the two arguments, which must be of the same type. Returns
Returns the minimum of the two arguments, which must be of the same type. Returns
Returns the numeric constant pi: 3.14159.
Raises the number to the specified power.
You can also use the ^ symbol:
Converts the given number from degrees to radians.
Rounds numbers to a specified number of digits. The
This example rounds every
Some databases, such as SQL Server, allow specification of a negative
Note: because ROUND may run into issues due to the underlying floating point representation of numbers – such as 9.405 rounding to 9.40 – it may be preferable to format the number to the desired number of decimal points rather than rounding. Formatting 9.405 to two decimal places will yield the expected 9.41.
Returns the sign of a number: The possible return values are -1 if the number is negative, 0 if the number is zero, or 1 if the number is positive.
If the average of the profit field is negative, then
Returns the sine of an angle. Specify the angle in radians.
Returns the square root of a number.
Returns the square of a number.
Returns the tangent of an angle. Specify the angle in radians.
Returns the expression if it is not null, otherwise returns zero. Use this function to use zero values instead of null values.
Create a number calculation
Follow along with the steps below to learn how to create a number calculation.
In Tableau Desktop, connect to the Sample - Superstore saved data source, which comes with Tableau.
Navigate to a worksheet and select Analysis > Create Calculated Field.
In the calculation editor that opens, do the following:
Name the calculated field Minimum Sales transaction
Enter the following formula:
When finished, click OK.
The new number calculation appears under Measures in the Data pane. Just like your other fields, you can use it in one or more visualisations.
When Minimum Sales is placed on Text on the Marks card in the worksheet, its name is changed to AGG(Minimum Sales), which indicates that it cannot be aggregated any further, since it is already aggregated down to the lowest level of detail (the smallest sales value for all records).
This example shows the minimum sales per category.
When subcategory is brought into the view, the minimum sales for each subcategory are shown.
Tableau Functions (Alphabetical)
Tableau Functions (by Category)