Title: Tableau - Functions
1Tableau - Functions
Tableau
Swipe
2Tableau - Functions
Any data analysis involves a lot of
calculations. In Tableau, the calculation editor
is used to apply calculations to the fields
being analyzed. Tableau has a number of inbuilt
functions which help in creating expressions for
complex calculations. Following are
the description of different categories of
functions.
3Types of Functions
Number Functions String Functions Date Functions
Logical Functions Aggregate Functions
4Number Functions
These are the functions used for numeric
calculations. They only take numbers as inputs.
Following are some examples of important
number functions. Function Description
Example
CEILING Rounds a number to (number) the nearest
integer of equal or greater
CEI LING(2.145) 3
value.
POWER (number, power) ROUND (number, decimals)
Raises the number to POWER(5,3) 125
the specified power.
Rounds the numbers ROUND(3.14152,2) to a
specified number 3.14 of digits.
5String Functions
String Functions are used for string
manipulation. Following are some important
string functions with examples
Function
Description
Example LEN("Tableau") 7
LEN (string)
Returns the
length of the string.
LTRIM (string)
Returns the
LTRIM(" Tableau ")
string wit h any leading spaces
"Tableau"
removed.
Returns string, with all characters uppercase.
UPPER("Tableau") "TABLEAU"
UPPER (string)
6Date Functions
- Tableau has a variety of date functions to carry
out calculations involving dates. - All the date functions use the dat e_part which
is a string indicating the part of the date such
as - month, day, or year. - Following tab le lists some examples of important
date functions.
7Function
Description
Example
DATEADD (date_part, increment, date)
Returns an increment added to
DATEADD ('month', 3, 2004-04-15)
the date. The type of 2004-0715 120000
increment is AM
specified in dat e_part.
DATENAME
Ret urns date_part of DATENAME('month',
(date_part, date,
date as a string. The 200404-15)
start_of_week "April"
start_of_wee k) DAY (date)
parameter is
opt ional.
DAY(2004-04-12) 12
Ret urns the day of
the given date as an
integer.
Returns the current date and time.
NOW( ) 2004-04-15 10821 PM
NOW( )
8Logical Functions
These functions evaluate some single value or the
result of an expression and produce a boolean
output.
Function
Des cription
Example
IF
IFNULL
The IFNULL function
NULL(Sales, 0)
(expression1,
returns the first
ales
S
expression2)
exp ression if the
result is not null, and returns the second
expression if it is null.
9Function
Description
Example
ISDATE (string)
The ISDATE function returns TRUE if the string
argument can
ISDATE("11/05/98") TRUE ISDATE("14/05/98")
FALSE
be converted to a
date, and FALSE if it cannot.
The MIN function returns the
MIN(expressi
on)
minimum of an exp ression across all records or
the min imum of two expressions for each record.
10Aggregate Functions
AVG(expression) Returns the average of all the
values in the expression. AVG can be used with
numeric fields only. Null values are
ignored. COUNT (expression) Returns the number
of items in a group. Null values are not
counted. MEDIAN (expression) Returns the median
of an expression across all records. Median can
only be used with numeric fields. Null values
are ignored. STDEV (expression) Returns the
statistical standard deviation of all values in
the given expression based on a sample of the
population.
11Topics for next Post
Tableau - Bar Chart Tableau - Line Chart
Tableau - Pie Chart Stay Tuned with