Tableau Functions - Tableau

What are Tableau Functions?

A number of inbuilt functions are provided by Tableau which enables to create expressions for complex calculations. The functions are categorised as follows:

  • Number Functions
  • String Functions
  • Date Functions
  • Logical Functions
  • Aggregate Functions

Number Functions

The Number functions are used for numeric calculations. Numbers are taken as inputs by the number functions. Some examples of number functions are:

Rounds a number to the nearest integer of equal or greater value.
CEILING(2.145) = 3
POWER(number, power)
Raises the number to the specified power.
POWER(5,3) = 125
ROUND(number, [decimals])
Rounds numbers to a specified number of digits.
ROUND(3.14152,2) = 3.14

String Functions

For string manipulations, string functions are used. Some examples of string functions are:

Returns the length of the string.
LEN("Tableau") = 7
Returns the string with any leading spaces removed.
LTRIM(" Tableau ") = "Tableau"
REPLACE(string, substring, replacement)
Searches string for substring and replaces it with replacement. If substring is not found, the string is not changed.
REPLACE("GreenBlueGreen", "Blue", "Red") = "GreenRedGreen"
Returns string, with all characters uppercase.
UPPER("Tableau") = "TABLEAU"

Date Functions

Tableau has a variety of date functions to carry out calculations involving dates. All the date functions use the date_part which is a string indicating the part of the date like - month, day or year. Some of the examples of Date functions are as follows:

DATEADD(date_part, increment, date)
Returns an increment added to date. The type of increment is specified in date_part.
DATEADD('month', 3, #2004-04-15#) = 2004-07-15 12:00:00 AM
DATENAME(date_part, date, [start_of_week])
Returns date_part of date as a string. The start_of_week parameter is optional.
DATENAME('month', #2004-04-15#) = "April"
Returns the day of the given date as an integer.
DAY(#2004-04-12#) = 12
NOW( )
Returns the current date and time.
NOW( ) = 2004-04-15 1:08:21 PM

Logical Functions

The functions which evaluate a single value or a result of an expression and give out a Boolean output are Logical Functions. Some of the examples of Logical functions are as follows:

IFNULL(expression1, expression2)
The IFNULL function returns the first expression if the result is not null, and returns the second expression if it is null.
IFNULL([Sales], 0) = [Sales]
The ISDATE function returns TRUE if the string argument can be converted to a date and FALSE if it cannot.
ISDATE("11/05/98") = TRUE
ISDATE("14/05/98") = FALSE
The MIN function returns the minimum of an expression across all records or the minimum of two expressions for each record.

Aggregate Functions

Some of the examples of aggregate functions are as follows:

Returns the average of all the values in the expression. AVG can be used with numeric fields only. Null values are ignored.
Returns the number of items in a group. Null values are not counted.
Returns the median of an expression across all records. Median can only be used with numeric fields. Null values are ignored.
Returns the statistical standard deviation of all values in the given expression based on a sample of the population.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

Tableau Topics