Quantcast
Channel: InterWorks
Viewing all articles
Browse latest Browse all 2697

Tableau Essentials: Calculated Fields - Number Functions

$
0
0

Not everyone is a Tableau guru, at least not yet. To help Tableau rookies, we’re starting from square one with the Tableau Essentials blog series. The series is intended to be an easy-to-read reference on the basics of using Tableau Software, particularly Tableau Desktop 8.1 and 8.2. Since there are so many cool features to cover in Tableau, the series will include several different posts. This is the tenth post in the series. Check out the full list on our Tableau Essentials blog channel. This is also the third post in the Calculated Fields sub-series.

Today, we’ll dig into another group of functions used for Tableau’s calculated fields. In part one, we looked at Logical Functions. For part two, we’ll examine Number Functions.

To start, let’s go back to the Calculated Fields window. Right-click in the sidebar (a.k.a. Data window) and select Create Calculated Field:

Create Calculated Field 

In the Calculated Field window, select Number from the Functions drop-down menu:

Functions > Number 

Let’s start examining each of these functions in more detail. Let’s put them into groupings by their type of number function just to help organize our overview:

Mathematical

ABS Function

ABS(number)

The ABS function returns the absolute value of the number. Example:

ABS([SalesVsGoal]) = 100

DEGREES Function

DEGREES(number)

This function converts the number or field from radians to degrees. For example:

DEGREES(PI( )/4) = 45.00

EXP Function

EXP(number)

The number e is the base of the natural logarithm. This function returns e raised to the power of the number, i.e. e^5 would be expressed as:

EXP(5) = 148.44

LN Function

LN(number)

This function returns the natural log of the number. If the number is less than or equal to zero, it will return NULL. Example:

LN(5) = 1.61

LOG Function

LOG(number,[base])

LOG returns the log of the number for the given base. If no base is provided, it will use base 10 by default. Example:

LOG(5,[2]) = 2.32

PI Function

PI()

This function returns the numeric constant of pi.

PI() = 3.14159

POWER Function

POWER(number, function)

The POWER function raises the number to the specified power. Example:

POWER(4,3) = 64

RADIANS Function

RADIAN(number)

This function converts the number from degrees to radians.

RADIANS(180) = 3.14159

ROUND Function

ROUND(number,[decimals])

This function rounds the number to the nearest integer or to a specified number of decimal places. Example:

ROUND([Profit], 2) = 7.62

SIGN Function

SIGN(number)

The SIGN function returns the sign of a number. For positive numbers, the function returns a 1. For zero, it returns a 0. And for negative numbers, it returns a -1. Example:

SIGN([Revenue]) = -1

SQRT Function

SQRT(number)

The SQRT function returns the square root of a number. Example:

SQRT (9)  =  3

SQUARE Function

SQUARE(number)

SQUAREreturns the square of a number. Example:

SQUARE(9) = 81

ZN Function

ZN(expression)

The ZN function evaluates the expression, and if it is NULL, then it will return a value of 0. Otherwise, the expression is returned as stated. Example:

ZN([Revenue]) = [Revenue]

Statistical

MAX Function

MAX(number, number)

The MAX function returns the maximum of a single expression across all records or the maximum of two expressions for each record. The two arguments must be the same type. This function will return a value of NULL if either argument is NULL. Example:

MAX(4,7) = 7

MIN Function

MIN(number, number)

Similar to the MAX function, the MIN function returns the minimum of a single expression across all records or the minimum of two expressions for each record. MIN returns a value of NULL if either of the two arguments is NULL. The two arguments must be of the same type. For example:

MIN(4,7) = 4

Trigonometric

ACOS Function

ACOS(number)

This function returns the arc cosine of a number. The result is in radians. Example:

ACOS(-1) = 3.14159

ASIN Function

ASIN(number)

ASIN returns the arc sine of a number. The result is in radians. Example:

ASIN(1) = 1.57079

ATAN Function

ATAN(number)

The ATAN function returns the arc tangent of a number. The result is in radians. Example:

ATAN(180) = 1.56524

ATAN2 Function

ATAN2(y number, x number)

The ATAN2 function returns the arc tangent of two given numbers. The result is in radians. Example: 

ATAN2(2, 1) = 1.10714

COS Function

COS(number)

COS returns the cosine of an angle. Specify the angle in radians. Example:

COS(PI()/4) = 0.70710

COT Function

COT(number)

This function returns the cotangent of an angle. Specify the angle in radians. Example: 

COT(PI()/4) = 1

SIN Function

SIN(number)

The SIN function returns the sine of an angle. Specify the angle in radians. Example:

SIN(0) = 0.70710

TAN Function

TAN(number)

This function returns the tangent of an angle. Specify the angle in radians. Example:

TAN(PI()/4) = 1.0

Depending on the nature of your reporting and your business, you many need to use Number Functions routinely or not at all. If you do need to use them or just wish to experiment to build your knowledge, Tableau will offer help when you click on any of these functions. A brief introduction and example of the function will be presented in the lower right-hand box on the Calculated Fields window.

Calculated Fields

Calculated fields can add a whole new layer of insight to your Tableau dashboards. The possibilities are practically endless, but we’ll be covering the fundamentals, especially functions, to help you build a foundational understanding of how and when to use them. Check back for more posts covering:

Introduction

  1. Logical Functions
  2. Number Functions
  3. Date Functions
  4. String Functions
  5. Type Conversion
  6. Aggregate Functions
  7. User Functions

Another great resource for functions is Dan Murray's best-selling guidebook, "Tableau Your Data!" It features a whole section devoted the functions we'll be covering in this series and much, much more.

More Tableau Essentials

Want to learn more about Tableau? We have several posts outlining all of Tableau's fantastic features. Check out the full list on our Tableau Essentials blog channel.

As always, let us know if you have any questions or comments about this post or Tableau in general. If you're looking for personalized training or help with something bigger, contact us directly!

 


Viewing all articles
Browse latest Browse all 2697

Trending Articles