# Tableau Functions

This article shows Tableau built-in functions such as Aggregate, Numeric, String, Date Functions, etc. You can use these functions to perform all kinds of operations on a dataset.

## Tableau Functions

This section covers all the available Tableau functions separated by the sections, and each section has information about the function. If you click the hyperlink (blue link), you can see the exclusive information and the practical Tableau example using the calculated fields.

1. ATTR Function: An attribute function returns the asterisk (*) if multiple values exist in the current context.

### Tableau Aggregate Functions

The Aggregate Functions include SUM, AVG, COUNT, COUNTD, MIN, MAX, VAR, VARP, STDEV, and STDEVP.

1. AVG Function returns the Average.
2. COUNT: It returns the total number of rows in a column. Please refer to the COUNT and Distinct COUNT (COUNTD) articles.
3. COUNTD: It returns the total number of distinct or unique rows in a column.
4. MIN returns the Minimum Value.
5. MAX returns the Maximum Value.
6. The Tableau SUM Function calculates the total value of the given column.
7. VAR and VARP find the Variance of the sample and the entire population.
8. STDEV and STDEVP find the Standard Deviation of the sample and the entire population.

### Conditional Functions

The Tableau functions below help deal with conditional-based results.

### Tableau Date Functions

To deal with dates, you can use the Date Functions. The Tableau date functions include YEAR, MONTH, DAY, NOW, TODAY, MAKEDATE, MAKETIME, MAKEDATETIME, ISDATE, DATEDIFF, DATEADD, DATEPART, DATENAME, DATETRUNC, and DATEPARSE.

1. YEAR return Year number.
2. MONTH return Month number.
3. DAY return Day number.
4. NOW function returns today’s date and time.
5. The Tableau TODAY function returns today’s date.
6. MAKEDATE return date from the year, month, and day.
7. MAKETIME return time from an hour, minute, and second.
8. MAKEDATETIME return date and time from the given Date & Time.
9. ISDATE checks whether the string is a date or not.
10. DATETRUNC returns the first day of the specified date part.
12. DATEDIFF Function finds and returns the difference between two dates.
13. DATEPART Function extracts the required part of the complete date.
14. DATEPARSE Function will convert the String field to the date.

### Tableau Logical Functions

The Logical Functions perform logical operations on columns or expressions. They are AND, NOT, OR, IIF, IF, ELSEIF, IF Else, CASE, ISNULL, IFNULL, ZN, IIF, etc. The AND Function performs the logical AND conjunction between two expressions.

### Tableau Math Functions

The Math Functions are ABS, DIV, DEGREES, RADIANS, EXP, FLOOR, CEILING, MIN, MAX, POWER, ROUND, SQRT, SQUARE, SIGN, SIN, COS, TAN, ACOS, ASIN, ATAN, ATAN2, LN, PI, and LOG.

• ABS returns the absolute positive value.
• DIV divides one number by another
• DEGREES will convert Radians to Degrees.
• EXP returns e raised to the power of the number.
• FLOOR returns the closest integer, which is less than or equal to a given value.
• The Tableau CEILING Function returns the closest integer which is greater than or equal to a given value.
• POWER finds the Power of a given number.
• ROUND returns the nearest integer value.
• SQRT finds the square root of a number.
• SQUARE finds the square of a number.
• SIN finds the Sine of a given value.
• COS finds the Cosine of a given value.
• COT calculates the Cotangent value.
• TAN finds the Tangent of a given value.
• ACOS finds the Arc cosine of a given value.
• ASIN finds the Arc Sine of a given value.
• ATAN finds the Arc Tangent of a given value.
• ATAN2 finds the Arc Tangent of two values.
• SIGN finds the integer Sign.
• PI returns a numeric value of 3.14.
• LN returns the natural logarithmic value of a number.
• LOG returns the logarithmic value of a number for a given base.

### Tableau NULL Functions

We can use the following Tableau NULL Functions to deal with table nulls.

1. ISNULL function returns true if the expression is NULL.
2. IFNULL function to replace NULL values with other values.
3. ZN function to replace NULL values with zeros.

### Tableau String Functions

The String Functions include LEN, ASCII, CHAR, CONTAINS, STARTSWITH, ENDSWITH, FIND, FINDNTH, LEFT, RIGHT, UPPER, LOWER, MID, REPLACE, SPLIT, SPACE, LTRIM, RTRIM, and TRIM.

• LEN returns the length of a string.
• ASCII returns the ASCII value of a character.
• CHAR converts the character for the given ASCII value.
• STARTSWITH returns True if the text starts with a given substring.
• ENDSWITH returns True if the text ends with a given substring.
• FIND returns the index position of a substring within the text.
• FINDNTH returns the index position of the nth substring occurrence.
• LEFT returns the leftmost characters up to a given index position.
• RIGHT returns the rightmost characters up to a given index position
• UPPER converts string to uppercase.
• LOWER converts string to lowercase.
• The Tableau MID function returns a substring from the string.
• REPLACE replaces a part of the string with a new text.
• SPACE return empty spaces.
• LTRIM, RTRIM, and TRIM functions remove the empty spaces from the left, Right, and both sides.
• The String split function divides the string and returns the part of it (substring) based on the sequence and token_number.
• CONTAINS Function: It searches the string for a given substring; if it is present, it returns True.

### Tableau Table Functions

Tableau Table Functions are FIRST, LAST, INDEX, SZE, TOTAL, RUNNING_SUM, RUNNING_AVG, RUNNING_MIN, RUNNING_MAX, RUNNING_COUNT, WINDOW_SUM, WINDOW_AVG, WINDOW_MIN, WINDOW_MAX, WINDOW_MEDIAN, WINDOW_VAR, WINDOW_VARP, WINDOW_STDEV, WINDOW_STDEVP, WINDOW_PERCENTILE, WINDOW_CORR, WINDOW_COVAR, WINDOW_COVARP.

1. The TOTAL function is a Table Calculation that returns the table total based on the Compute using option in the Table calculation partition.
2. INDEX function: It helps to find the TOP N (3, 5, or 10) records, products, cities, or customers.
3. WINDOW_AVG function finds the average of the whole window. This example calculates KPI using the window average.
4. The LAST Function is a Table Function to find the recent Order Date.

### Type Conversion Functions

The Tableau Type Conversion Functions include STR, DATE, DATETIME, INT, FLOAT, and DATEPARSE. These are helpful in converting the field’s or column’s data type from one to another.

• STR converts the given expression to a string.
• DATE returns a date from an expression, number, or string.
• DATETIME returns the date and time from an expression, number, or string.
• INT returns an integer from a given expression.
• FLOAT converts a given expression to float.
• DATEPARSE will convert the String to the date.

### Calculations

The following are the important calculations in Tableau, where we use the built-in functions.

1. Calculate the Date Difference – This page shows how to find the number of days, months, and years between two dates.
2. Get Date From Integer – This page shows how to convert the integer field or column to date and time.
3. Calculate Rank – The Best Way
4. Cumulative Sum, also known as Running sum, is the sum of all the preceding rows within a column.
5. Date Calculation using Parameter
6. Running Total
7. Moving Average
8. Percentage Of Total
9. Percentage Difference
10. YTD Table Calculations