0% found this document useful (0 votes)
38 views

Number Functions

This document introduces number functions in Tableau and provides examples of functions like ABS, CEILING, and FLOOR. It lists over 20 common number functions, describes what each does and provides basic syntax. The document also gives an example of creating a calculation using the ABS function to return the absolute value of numbers in a field.

Uploaded by

phamthu1503
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

Number Functions

This document introduces number functions in Tableau and provides examples of functions like ABS, CEILING, and FLOOR. It lists over 20 common number functions, describes what each does and provides basic syntax. The document also gives an example of creating a calculation using the ABS function to return the absolute value of numbers in a field.

Uploaded by

phamthu1503
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Number Functions

This article introduces number functions and their uses in Tableau. It also demonstrates how to
create a number calculation using an example.

In this article
Why use number functions

List of number functions available in Tableau

Create a number calculation 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:

ABS[Budget Variance]

Therefore, ABS(-7) = 7.

Number functions available in Tableau


Function Syntax Description
Returns the absolute value of the given number.

Examples:

ABS ABS(number) ABS(-7) = 7


ABS([Budget Variance])

The second example returns the absolute value for all the
numbers contained in the Budget Variance field.
Returns the arc cosine of the given number. The result is in
radians.
ACOS ACOS(number)
Example:

ACOS(-1) = 3.14159265358979
Returns the arc sine of a given number. The result is in radians.

ASIN ASIN(number) Example:

ASIN(1) = 1.5707963267949
Returns the arc tangent of a given number. The result is in
radians.
ATAN ATAN(number)
Example:

ATAN(180) = 1.5652408283942
Returns the arc tangent of two given numbers (x and y). The
result is in radians.
ATAN2(y number,
ATAN2 x number) Example:

ATAN2(2, 1) = 1.10714871779409
Rounds a number to the nearest integer of equal or greater
value.

Example:

CEILING(3.1415) = 4

Availability by data source:


Data Source Support
Microsoft Access Not supported
CEILING CEILING(number) Microsoft Excel Supported
Text File Supported
Statistical File Supported
Tableau Server Supported
Actian Vector Not supported
Amazon Aurora Not supported
Amazon EMR Hadoop Hive Supported
Amazon Redshift Not supported
Aster Database Not supported
Cloudera Hadoop Supported
DataStax Enterprise Supported
EXASOL Not supported
Firebird Not supported
Google Analytics Supported
Google BigQuery Supported
Google Cloud SQL Not supported
Hortonworks Hadoop Hive Supported
IBM BigInsights Not supported
IBM DB2 Not supported
IBM PDA (Netezza) Not supported
MapR Hadoop Hive Supported
MarkLogic Not supported
Microsoft Analysis Services Not supported
Microsoft PowerPivot Not supported
Microsoft SQL Server Not supported
MySQL Not supported
Oracle Not supported
Oracle Essbase Not supported
Actian Matrix (ParAccel) Not supported
Pivotal Greenplum Not supported
PostgreSQL Not supported
Progress OpenEdge Not supported
Salesforce Supported
SAP HANA Not supported
SAP Sybase ASE Not supported
SAP Sybase IQ Not supported
Spark SQL Supported
Splunk Not supported
Teradata Not supported
Teradata OLAP Connector Not supported
Vertica Not supported
Returns the cosine of an angle. Specify the angle in radians.

COS COS(number) Example:

COS(PI( ) /4) = 0.707106781186548

COT(number)
Returns the cotangent of an angle. Specify the angle in radians.
COT
Example:

COT(PI( ) /4) = 1
Converts a given number in radians to degrees.

DEGREES DEGREES(number) Example:

DEGREES(PI( )/4) = 45.0


Returns the integer part of a division operation, in which
integer1 is divided by integer2.
DIV(integer1,
DIV
integer2) Example:

DIV(11,2) = 5
Returns e raised to the power of the given number.

EXP EXP(number) Examples:

EXP(2) = 7.389
EXP(-[Growth Rate]*[Time])
Rounds a number to the nearest integer of equal or lesser
value.

Example:

FLOOR(3.1415) = 3

Availability by data source:


Data Source Support
Microsoft Access Not supported
Microsoft Excel Supported
Text File Supported
FLOOR FLOOR(number)
Statistical File Supported
Tableau Server Supported
Actian Vector Not supported
Amazon Aurora Not supported
Amazon EMR Hadoop Hive Supported
Amazon Redshift Not supported
Aster Database Not supported
Cloudera Hadoop Supported
DataStax Enterprise Supported
EXASOL Not supported
Firebird Not supported
Google Analytics Supported
Google BigQuery Supported
Google Cloud SQL Not supported
Hortonworks Hadoop Hive Supported
IBM BigInsights Not supported
IBM DB2 Not supported
IBM Netezza Not supported
MapR Hadoop Hive Supported
MarkLogic Not supported
Microsoft Analysis Services Not supported
Microsoft PowerPivot Not supported
Microsoft SQL Server Not supported
MySQL Not supported
Oracle Not supported
Oracle Essbase Not supported
ParAccel Not supported
Pivotal Greenplum Not supported
PostgreSQL Not supported
Progress OpenEdge Not supported
Salesforce Supported
SAP HANA Not supported
SAP Sybase ASE Not supported
SAP Sybase IQ Not supported
Spark SQL Supported
Splunk Not supported
Teradata Not supported
Teradata OLAP Connector Not supported
Vertica Not supported
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


HEXBINX(number, for hexagonal bins. Hexagonal bins are an efficient and elegant
HEXBINX number)
option for visualizing data in an x/y plane such as a map.
Because the bins are hexagonal, each bin closely approximates
a circle and minimizes variation in the distance from the data
point to the center of the bin. This makes the clustering both
more accurate and informative.
Example:

HEXBINX([Longitude], [Latitude])
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.
HEXBINY(number,
HEXBINY number)
Example:

HEXBINY([Longitude], [Latitude])

LN(number)
Returns the natural logarithm of a number. Returns Null if
LN
number is less than or equal to 0.
LOG(number [, Returns the logarithm of a number for the given base. If the
LOG base]) base value is omitted, base 10 is used.
Returns the maximum of the two arguments, which must be of
the same type. Returns Null if either argument is Null. MAX
can also be applied to a single field in an aggregate calculation.
MAX(number,
MAX number) Examples:

MAX(4,7)
MAX(Sales,Profit)
MAX([First Name],[Last Name])
Returns the minimum of the two arguments, which must be of
the same type. Returns Null if either argument is Null. MIN
can also be applied to a single field in an aggregate calculation.
MIN(number,
MIN number) Examples:

MIN(4,7)
MIN(Sales,Profit)
MIN([First Name],[Last Name])
PI PI( ) Returns the numeric constant pi: 3.14159.
Raises the number to the specified power.

Examples:

POWER(number, POWER(5,2) = 52 = 25
POWER power) POWER(Temperature, 2)

You can also use the ^ symbol:

5^2 = POWER(5,2) = 25
Converts the given number from degrees to radians.
RADIANS RADIANS(number)
Example:

RADIANS(180) = 3.14159
Rounds numbers to a specified number of digits. The
decimals argument specifies how many decimal points of
precision to include in the final result. If decimals is omitted,
number is rounded to the nearest integer.

Example:
ROUND(number,
ROUND [decimals]) This example rounds every Sales value to an integer:

ROUND(Sales)

Some databases, such as SQL Server, allow specification of a


negative length, where -1 rounds number to 10's, -2 rounds to
100's, and so on. This is not true of all databases. For example,
it is not true of Excel or Access.
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.

SIGN SIGN(number) Example:

If the average of the profit field is negative, then

SIGN(AVG(Profit)) = -1
Returns the sine of an angle. Specify the angle in radians.

SIN SIN(number) Examples:

SIN(0) = 1.0
SIN(PI( )/4) = 0.707106781186548
Returns the square root of a number.

SQRT SQRT(number) Example:

SQRT(25) = 5
Returns the square of a number.

SQUARE SQUARE(number) Example:

SQUARE(5) = 25
Returns the tangent of an angle. Specify the angle in radians..
TAN TAN(number)
Example:

TAN(PI ( )/4) = 1.0


Returns the expression if it is not null, otherwise returns zero.
Use this function to use zero values instead of null values.
ZN ZN(expression)
Example:

ZN([Profit]) = [Profit]

Create a number calculation


Follow along with the steps below to learn how to create a number calculation.

1. In Tableau Desktop, connect to the Sample - Superstore saved data source, which comes
with Tableau.

2. Navigate to a worksheet and select Analysis > Create Calculated Field.

3. In the calculation editor that opens, do the following:

o Name the calculated field Minimum Sales transaction

o Enter the following formula:

MIN(Sales)

o 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 visualizations.

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.

You might also like