Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Tableau function


May 26, 2021 Tableau


Table of contents


Any data analysis involves a lot of computation. /b10> In Tableau, the calculation editor is used to apply calculations to the fields being analyzed. /b11> Tableau has many built-in functions that help create complex evaluated expressions.

A description of the different categories of features is given below.

  • The numeric function
  • String function
  • The date function
  • Logical functions
  • The aggregate function

The numeric function

These are functions for numerical calculations. /b10> They only accept numbers as inputs. H ere are some examples of important numeric functions.

Function Describe Example
CEILING(number) Round the number to the nearest integer equal to or greater than the value. CEILING(2.145)= 3
POWER (number, power)
Power the numbers. POWER(5,3)= 125
ROUND (number, [decimals])
Round the numbers to the specified number of digits. ROUND(3.14152,2)= 3.14

String function

String functions are used for string operations. /b10> Here are some important string functions and examples.

Example Describe Example
LEN(string) Returns the length of the string. LEN(“Tableau")= 7
LTRIM(string) Returns a string that deleted any leading spaces. LTRIM(“Tableau")=“Tableau"
REPLACE(string,substring,replacement) Search for strings to get substrings and replace them with replacements. /b10> If no substring is found, the string is not changed. REPLACE(“GreenBlueGreen",“Blue",“Red")=“GreenRedGreen"
UPPER(string) Returns a string, all characters are capital. UPPER(“Tableau")=“TABLEAU"

The date function

Tableau has a variety of date functions to perform calculations involving dates. /b10> All date functions use date_part, which is a string that represents part of a date, such as - month, day, or year. /b11> Here are some examples of important date functions.

Example Describe Example
DATEADD(date_part,increment,date) Returns the increment added to the date. /b10> The type of increment date_part in the file. DATEADD(\'month\',3,#2004-04-15#)= 2004-07-15 12:00:00 AM
DATENAME (date_part, date, start_of_week) The date on which the date of the date of the date is passed back as a string. /b10> start_of_week parameters are optional. DATENAME ('month', #2004-04-15)
DAY(date) Returns the date of a 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

These functions evaluate a single value or result of an expression and give a Boolean output.

Example Describe Example
IFNULL(expression1,expression2) If the result is not null, the IFNULL function returns the first expression, and if the result is empty, the second expression is returned. IFNULL([Sales],0)= [Sales]
ISDATE(string) If string parameters can be converted to dates, the ISDATE function returns TRUE, and if they cannot be converted to dates, FALSE. ISDATE(“11/05/98")= TRUE

ISDATE(“14/05/98")= FALSE
MIN(expression) The MIN function returns the minimum value of all recorded expressions or a minimum of two expressions per record.

The aggregate function

Example Describe Example
AVG(expression) Returns the average of all values in the expression. /b10> AVG can only be used with numeric fields. /b11> The empty value is ignored.
COUNT(expression) Returns the number of items in the group. /b10> Empty values are not calculated.
MEDIAN(expression) Returns the median expression for all records. /b10> The median can only be used with numeric fields. /b11> The empty value is ignored.
STDEV(expression) Returns a statistical standard deviation for all values in a given expression based on the sample population.