The Tableau functions in this reference are organized by category. Click a category to browse its functions. Or press Ctrl+F (CommandF on a Mac) to open a search box that you can use to search the page for a specific function.
Function 
Syntax 
Description 

ABS 

Returns the absolute value of the given number. Examples:
The second example returns
the absolute value for all the numbers contained in the 

ACOS 

Returns the arc cosine of the given number. The result is in radians. Example:


ASIN 

Returns the arc sine of a given number. The result is in radians. Example:


ATAN 
ATAN(number)

Returns the arc tangent of a given number. The result is in radians. Example:


ATAN2 

Returns the arc tangent of two given numbers (x and y). The result is in radians. Example:


CEILING 



COS 

Returns the cosine of an angle. Specify the angle in radians. Example:


COT 

Returns the cotangent of an angle. Specify the angle in radians. Example:


DEGREES 

Converts a given number in radians to degrees. Example:


DIV 
DIV(integer1, integer2) 
Returns the integer part of a division operation, in which integer1 is divided by integer2. Example:


EXP 

Returns e raised to the power of the given number. Examples:


FLOOR 



HEXBINX 

Maps an x, y coordinate to the xcoordinate of the nearest hexagonal bin. The bins have side length 1, so the inputs may need to be scaled appropriately. HEXBINX and HEXBINY are binning and plotting functions for hexagonal bins. Hexagonal bins are an efficient and elegant option for visualizing data in an x/y plane such as a map. Because the bins are hexagonal, each bin closely approximates a circle and minimizes variation in the distance from the data point to the center of the bin. This makes the clustering both more accurate and informative. Example:


HEXBINY 

Maps an x, y coordinate to the ycoordinate of the nearest hexagonal bin. The bins have side length 1, so the inputs may need to be scaled appropriately. Example:


LN 

Returns the natural logarithm
of a number. Returns 

LOG 

Returns the logarithm of a number for the given base. If the base value is omitted, base 10 is used. 

MAX 

Returns the maximum
of the two arguments, which must be of the same type. Returns Examples:


MIN 

Returns the minimum
of the two arguments, which must be of the same type. Returns Examples:


PI 

Returns the numeric constant pi: 3.14159. 

POWER 

Raises the number to the specified power. Examples:
You can also use the ^ symbol:


RADIANS 

Converts the given number from degrees to radians. Example:


ROUND 

Rounds numbers
to a specified number of digits. The Example: This example rounds
every
Some databases, such as SQL Server, allow specification of a negative 

SIGN 

Returns the sign of a number: The possible return values are 1 if the number is negative, 0 if the number is zero, or 1 if the number is positive. Example: If the average of the profit field is negative, then


SIN 

Returns the sine of an angle. Specify the angle in radians. Examples:


SQRT 

Returns the square root of a number. Example:


SQUARE 

Returns the square of a number. Example:


TAN 

Returns the tangent of an angle. Specify the angle in radians.. Example:


ZN 

Returns the expression if it is not null, otherwise returns zero. Use this function to use zero values instead of null values. Example:

Function 
Syntax 
Definition 

ASCII 
ASCII(string)

Returns the ASCII code
for the first character of Example:


CHAR 
CHAR(number)

Returns the character encoded
by the ASCII code Example:


CONTAINS 
CONTAINS(string, substring)

Returns true if the given string contains the specified substring. Example:


ENDSWITH 
ENDSWITH(string, substring)

Returns true if the given string ends with the specified substring. Trailing white spaces are ignored. Example:


FIND 
FIND(string, substring, [start])

Returns
the index position of Examples:


FINDNTH 
FINDNTH(string, substring, occurrence)

Returns the position of the nth occurrence of substring within the specified string, where n is defined by the occurrence argument. Note: FINDNTH is not available for all data sources. Example:


LEFT 
LEFT(string, number)

Returns the leftmost number of characters in the string. Example:


LEN 
LEN(string)

Returns the length of the string. Example:


LOWER 
LOWER(string)

Returns Example:


LTRIM 
LTRIM(string)

Returns the string with any leading spaces removed. Example:


MAX 

Returns the maximum of Example:


MID 
(MID(string, start, [length])

Returns the
string starting at index position Examples:


MIN 
MIN(a, b)

Returns the minimum of Example:


REPLACE 
REPLACE(string, substring, replacement)

Searches
Example:


RIGHT 
RIGHT(string, number)

Returns the rightmost
number of characters in Example:


RTRIM 
RTRIM(string)

Returns Example:


SPACE 
SPACE(number)

Returns a string that is
composed of the specified Example:


SPLIT(string, delimiter, token number)



STARTSWITH 
STARTSWITH(string, substring)

Returns
true if Example:


TRIM 
TRIM(string)

Returns the string with leading and trailing spaces removed. Example:


UPPER 
UPPER(string)

Returns string, with all characters uppercase. Example:

Tableau provides a variety of date functions. Many of the examples
use the #
symbol with date expressions. See Literal expression syntax for an explanation of this symbol.
Additionally, many date functions use date_part
,
which is a constant string argument. The valid date_part
values
that you can use are:
date_part  Values 

'year'

Fourdigit year 
'quarter'

14 
'month'

112 or "January", "February", and so on 
'dayofyear'

Day of the year; Jan 1 is 1, Feb 1 is 32, and so on 
'day'

131 
'weekday'

17 or "Sunday", "Monday", and so on 
'week'

152 
'hour'

023 
'minute'

059 
'second'

060 
Note: Date functions do not take account of the configured fiscal year start. See Fiscal Dates.
Function 
Syntax 
Description 
DATEADD 

Returns the specified date with the specified number Supports ISO 8601 dates. Example:
This expression adds three months to the date 
DATEDIFF 

Returns
the difference between The Supports ISO 8601 dates. Examples:
The first expression returns 1 because when 
DATENAME 

Returns Supports ISO 8601 dates. Examples:

DATEPARSE 
DATEPARSE(date_format, [date_string])

Returns [date_string] as a date. The date_format argument will describes how the [string] field is arranged. Because of the variety of ways the string field can be ordered, the date_format must match exactly. For a full explanation, see Convert a field to a date field. Example:
Note: This function is available through the following connectors: nonlegacy Excel and text file connections, Amazon EMR Hadoop Hive, Cloudera Hadoop, Google Sheets, Hortonworks Hadoop Hive, MapR Hadoop Hive, MySQL, Oracle, PostgreSQL, and Tableau extracts. Some formats may not be available for all connections. Note: DATEPARSE is not supported on Hive variants. Only Denodo, Drill, and Snowflake are supported. 
DATEPART 

Returns The
Note: When the Supports ISO 8601 dates. Examples:

DATETRUNC 

Truncates the
specified date to the accuracy specified by the date_part. This
function returns a new date. For example, when you truncate a date
that is in the middle of the month at the month level, this function
returns the first day of the month. The Supports ISO 8601 dates. Examples:

DAY 

Returns the day of the given date as an integer. Example:

ISDATE 

Returns true if a given string is a valid date. Example:

MAKEDATE 

Returns a date value constructed from the specified year, month, and date. Available for Tableau Data Extracts. Check for availability in other data sources. Example:

MAKEDATETIME 

Returns a datetime that combines a date and a time. The date can be a date, datetime, or a string type. The time must be a datetime. Note: This function is available only for MySQLcompatible connections (which for Tableau are MySQL and Amazon Aurora). Examples:

MAKETIME 

Returns a date value constructed from the specified hour, minute, and second. Available for Tableau Data Extracts. Check for availability in other data sources. Example:

MAX 

Usually
applied to numbers but also works on dates. Returns the maximum
of Examples:

MIN 

Usually
applied to numbers but also works on dates. Returns the minimum
of Examples:

MONTH 

Returns the month of the given date as an integer. Example:

NOW 

Returns the current local system date and time. Example:

QUARTER 
QUARTER ( )

Returns the quarter of the given date as an integer. Example:

TODAY 

Returns the current date. Example:

WEEK 
WEEK( )

Returns the week of the given date as an integer. Example:

YEAR 

Returns the year of the given date as an integer. Example:

ISOQUARTER 
ISOQUARTER (date)

Returns the ISO8601 weekbased quarter of a given date as an integer. Example:

ISOWEEK 
ISOWEEK (date)

Returns the ISO8601 weekbased week of a given date as an integer. Example:

ISOWEEKDAY 
ISOWEEKDAY (date)

Returns the ISO8601 weekbased weekday of a given date as an integer. Example:

ISOYEAR 
ISOYEAR (date)

Returns the ISO8601 weekbased year of a given date as an integer. Example:

Function 
Syntax 
Description 
IN 
<expr1> IN <expr2>

Returns TRUE if any value in The values in Examples:

AND 
IF <expr1> AND <expr2> THEN <then> END

Performs a logical conjunction on two expressions. Example:

CASE 
CASE <expression> WHEN <value1> THEN <return1> WHEN
<value2> THEN <return2> ... ELSE <default return> END

Performs logical tests and returns
appropriate values. The CASE function evaluates CASE also supports WHEN IN construction, such as
The values that WHEN IN compare to must be a set, list of literal values, or combined field. Additional notes
Examples:

ELSE 
IF <expr> THEN <then> ELSE <else> END

Tests a series of expressions returning the <then> value for the first true <expr>. Example:

ELSEIF 
IF <expr> THEN <then> [ELSEIF <expr2> THEN <then2>...] [ELSE <else>] END

Tests a series of expressions returning the <then> value for the first true <expr>. Example:

END 
IF <expr> THEN <then> [ELSEIF <expr2> THEN <then2>...] [ELSE <else>] END

Tests a series of expressions returning the <then> value for the first true <expr>. Must be placed at the end of an expression. Example:

IF 
IF <expr> THEN <then> [ELSEIF <expr2> THEN <then2>...] [ELSE <else>] END

Tests a series of expressions returning the <then> value for the first true <expr>. Example:

IFNULL 
IFNULL(expr1, expr2)

Returns <expr1> if it is not null, otherwise returns <expr2>. Example:

IIF 
IIF(test, then, else, [unknown])

Checks whether a condition is met, and returns one value if TRUE, another value if FALSE, and an optional third value or NULL if unknown. Example:

ISDATE 
ISDATE(string)

Returns true if a given string is a valid date. Example:

ISNULL 
ISNULL(expression)

Returns true if the expression is NULL (does not contain valid data). Example:

MAX 
MAX(expression) or Max(expr1, expr2) 
Returns the maximum of a single expression across all records or the maximum of two expressions for each record. Example:

MIN 
MIN(expression) or MIN(expr1, expr2) 
Returns the minimum of an expression across all records or the minimum of two expressions for each record. Example:

NOT 
IF NOT <expr> THEN <then> END

Performs logical negation on an expression. Example:

OR 
IF <expr1> OR <expr2> THEN <then> END

Performs a logical disjunction on two expressions. Example:

THEN 
IF <expre> THEN <then> [ELSEIF ,expr2> THEN <then2>...] [ELSE <else>] END

Tests a series of expressions returning the <then> value for the first true <expr>. Example:

WHEN 
CASE <expr> WHEN <Value1> THEN <return1> ... [ELSE <else>] END

Finds the first <value> that matches <expr> and returns the corresponding <return>. Example:

ZN 
ZN(expression)

Returns <expression> if it is not null, otherwise returns zero. Example:

Aggregations and floatingpoint arithmetic: The results of some aggregations may not always be exactly as expected. For example, you may find that the Sum function returns a value such as 1.42e14 for a column of numbers that you know should sum to exactly 0. This happens because the Institute of Electrical and Electronics Engineers (IEEE) 754 floatingpoint standard requires that numbers be stored in binary format, which means that numbers are sometimes rounded at extremely fine levels of precision. You can eliminate this potential distraction by using the ROUND function (see Number Functions) or by formatting the number to show fewer decimal places.
Function 
Syntax 
Definition 
ATTR 

Returns the value of the expression if it has a single value for all rows. Otherwise returns an asterisk. Null values are ignored. 
AVG 

Returns the average of all the values in the expression. AVG can be used with numeric fields only. Null values are ignored. 
COLLECT 

An aggregate calculation that combines the values in the argument field. Null values are ignored. Note: The COLLECT function can only be used with spatial fields. Example:

CORR 

Returns the Pearson correlation coefficient of two expressions. The Pearson correlation measures the linear relationship between two variables. Results range from 1 to +1 inclusive, where 1 denotes an exact positive linear relationship, as when a positive change in one variable implies a positive change of corresponding magnitude in the other, 0 denotes no linear relationship between the variance, and −1 is an exact negative relationship. CORR is available with the following data sources:
For other data sources, consider either extracting the data or using WINDOW_CORR. See Table Calculation Functions. Note: The square of a CORR result is equivalent to the RSquared value for a linear trend line model. See Trend Line Model Terms. Example: You can use CORR to visualize correlation in a disaggregated scatter plot. The way to do this is to use a tablescoped level of detail expression. For example:
With a level of detail expression, the correlation is run over all rows. If you used a formula like See TableScoped 
COUNT 

Returns the number of items in a group. Null values are not counted. 
COUNTD 

Returns the number of distinct items in a group. Null values are not counted. This function is not available in the following cases: workbooks created before Tableau Desktop 8.2 that use Microsoft Excel or text file data sources, workbooks that use the legacy connection, and workbooks that use Microsoft Access data sources. Extract your data into an extract file to use this function. See Extract Your Data. 
COVAR 

Returns the sample covariance of two expressions. Covariance quantifies how two variables change together. A positive covariance indicates that the variables tend to move in the same direction, as when larger values of one variable tend to correspond to larger values of the other variable, on average. Sample covariance uses the number of nonnull data points n  1 to normalize the covariance calculation, rather than n, which is used by the population covariance (available with the COVARP function). Sample covariance is the appropriate choice when the data is a random sample that is being used to estimate the covariance for a larger population. COVAR is available with the following data sources:
For other data sources, consider either extracting the data or using WINDOW_COVAR. See Table Calculation Functions. If expression1 and expression2 are the same—for example, COVAR([profit], [profit])—COVAR returns a value that indicates how widely values are distributed. Note: The value of COVAR(X, X) is equivalent to the value of VAR(X) and also to the value of STDEV(X)^2. Example: The following formula returns the sample covariance of Sales and Profit.

COVARP 

Returns the population covariance of two expressions. Covariance quantifies how two variables change together. A positive covariance indicates that the variables tend to move in the same direction, as when larger values of one variable tend to correspond to larger values of the other variable, on average. Population covariance is sample covariance multiplied by (n1)/n, where n is the total number of nonnull data points. Population covariance is the appropriate choice when there is data available for all items of interest as opposed to when there is only a random subset of items, in which case sample covariance (with the COVAR function) is appropriate. COVARP is available with the following data sources:
For other data sources, consider either extracting the data or using WINDOW_COVARP. See Table Calculation Functions. If expression1 and expression2 are the same—for example, COVARP([profit], [profit])—COVARP returns a value that indicates how widely values are distributed. Note: The value of COVARP(X, X) is equivalent to the value of VARP(X) and also to the value of STDEVP(X)^2. Example: The following formula returns the population covariance of Sales and Profit.

MAX 

Returns the maximum of an expression across all records. If the expression is a string value, this function returns the last value where last is defined by alphabetical order. 
MEDIAN 

Returns the median of an expression across all records. Median can only be used with numeric fields. Null values are ignored. This function is not available for workbooks created before Tableau Desktop 8.2 or that use legacy connections. It is also not available for connections using any of the following data sources:
For other data source types, you can extract your data into an extract file to use this function. See Extract Your Data. 
MIN 

Returns the minimum of an expression across all records. If the expression is a string value, this function returns the first value where first is defined by alphabetical order. 
PERCENTILE 

Returns the percentile value from the given expression corresponding to the specified number. The number must be between 0 and 1 (inclusive)—for example, 0.66, and must be a numeric constant. This function is available for the following data sources.
For other data source types, you can extract your data into an extract file to use this function. See Extract Your Data. 
STDEV 

Returns the statistical standard deviation of all values in the given expression based on a sample of the population. 
STDEVP 

Returns the statistical standard deviation of all values in the given expression based on a biased population. 
SUM 

Returns the sum of all values in the expression. SUM can be used with numeric fields only. Null values are ignored. 
VAR 

Returns the statistical variance of all values in the given expression based on a sample of the population. 
VARP 

Returns the statistical variance of all values in the given expression on the entire population. 
Function 
Syntax 
Description 
FULLNAME 

Returns the full name for the current user. This is the Tableau Server or Tableau Cloud full name when the user is signed in; otherwise the local or network full name for the Tableau Desktop user. Example:
If manager Dave Hallsten is signed in, this example returns True only if the Manager field in the view contained Dave Hallsten. When used as a filter, this calculated field can be used to create a user filter that only shows data that is relevant to the person signed in to the server. 
ISFULLNAME 

Returns true if the current user's full name matches the specified full name, or false if it does not match. This function uses the Tableau Server or Tableau Cloud full name when the user is signed in; otherwise it uses the local or network full name for the Tableau Desktop user. Example:
This example returns true if Dave Hallsten is the current user, otherwise it returns false. 
ISMEMBEROF 

Returns true if the person currently using Tableau is a member of a group that matches the given string. If the person currently using Tableau is signed in, the group membership is determined by groups on Tableau Server or Tableau Cloud. If the person is not signed in, this function returns NULL. Note: The function will return a "True" value if the given string is "All Users", whether signed in to Tableau Server or Tableau Cloud. The ISMEMBEROF() function will also accept Active Directory domains. The Active Directory domain must be declared in the calculation with the group name. Example:

ISUSERNAME 

Returns true if the current user's username matches the specified username, or false if it does not match. This function uses the Tableau Server or Tableau Cloud username when the user is signed in; otherwise it uses the local or network username for the Tableau Desktop user. Example:
This example returns true if dhallsten is the current user; otherwise it returns false. Note: "All Users" will always return as true. 
USERDOMAIN 

Returns the domain for the current user when the user is signed on to Tableau Server. Returns the Windows domain if the Tableau Desktop user is on a domain. Otherwise this function returns a null string. Example:

USERNAME 

Returns the username for the current user. This is the Tableau Server or Tableau Cloud username when the user is signed in; otherwise it is the local or network username for the Tableau Desktop user. Example:
If the manager dhallsten was signed in, this function would only return True when the Manager field in the view is dhallsten. When used as a filter this calculated field can be used to create a user filter that only shows data that is relevant to the person signed in to the server. 
FIRST( )
Returns the number of rows from the current row to the first row in the partition. For example, the view below shows quarterly sales. When FIRST() is computed within the Date partition, the offset of the first row from the second row is 1.
Example
When the current row index is 3, FIRST()
= 2
.
INDEX( )
Returns the index of the current row in the partition, without any sorting with regard to value. The first row index starts at 1. For example, the table below shows quarterly sales. When INDEX() is computed within the Date partition, the index of each row is 1, 2, 3, 4..., etc.
Example
For the third row in the partition, INDEX() = 3
.
LAST( )
Returns the number of rows from the current row to the last row in the partition. For example, the table below shows quarterly sales. When LAST() is computed within the Date partition, the offset of the last row from the second row is 5.
Example
When the current row index is 3
of 7, LAST() = 4
.
LOOKUP(expression, [offset])
Returns the
value of the expression in a target row, specified as a relative
offset from the current row. Use FIRST() + n and LAST()  n as part of your offset definition for
a target relative to the first/last rows in the partition. If offset
is omitted, the row to compare to can be set on the field menu. This function returns
NULL if the target row cannot be determined.
The view below shows quarterly sales. When LOOKUP (SUM(Sales), 2)
is computed within the Date partition, each row shows the sales
value from 2 quarters into the future.
Example
LOOKUP(SUM([Profit]),
FIRST()+2)
computes the SUM(Profit) in the third row of the partition.
MODEL_EXTENSION_BOOL (model_name, arguments, expression)
Returns the boolean result of an expression as calculated by a named model deployed on a TabPy external service.
Model_name is the name of the deployed analytics model you want to use.
Each argument is a single string that sets the input values that the deployed model accepts, and is defined by the analytics model.
Use expressions to define the values that are sent from Tableau to the analytics model. Be sure to use aggregation functions (SUM, AVG, etc.) to aggregate the results.
When using the function, the data types and order of the expressions must match that of the input arguments.
Example
MODEL_EXTENSION_BOOL ("isProfitable","inputSales", "inputCosts", SUM([Sales]), SUM([Costs]))
MODEL_EXTENSION_INT (model_name, arguments, expression)
Returns an integer result of an expression as calculated by a named model deployed on a TabPy external service.
Model_name is the name of the deployed analytics model you want to use.
Each argument is a single string that sets the input values that the deployed model accepts, and is defined by the analytics model.
Use expressions to define the values that are sent from Tableau to the analytics model. Be sure to use aggregation functions (SUM, AVG, etc.) to aggregate the results.
When using the function, the data types and order of the expressions must match that of the input arguments.
Example
MODEL_EXTENSION_INT ("getPopulation", "inputCity", "inputState", MAX([City]), MAX ([State]))
MODEL_EXTENSION_REAL (model_name, arguments, expression)
Returns a real result of an expression as calculated by a named model deployed on a TabPy external service.
Model_name is the name of the deployed analytics model you want to use.
Each argument is a single string that sets the input values that the deployed model accepts, and is defined by the analytics model.
Use expressions to define the values that are sent from Tableau to the analytics model. Be sure to use aggregation functions (SUM, AVG, etc.) to aggregate the results.
When using the function, the data types and order of the expressions must match that of the input arguments.
Example
MODEL_EXTENSION_REAL ("profitRatio", "inputSales", "inputCosts", SUM([Sales]), SUM([Costs]))
MODEL_EXTENSION_STRING (model_name, arguments, expression)
Returns the string result of an expression as calculated by a named model deployed on a TabPy external service.
Model_name is the name of the deployed analytics model you want to use.
Each argument is a single string that sets the input values that the deployed model accepts, and is defined by the analytics model.
Use expressions to define the values that are sent from Tableau to the analytics model. Be sure to use aggregation functions (SUM, AVG, etc.) to aggregate the results.
When using the function, the data types and order of the expressions must match that of the input arguments.
Example
MODEL_EXTENSION_STR ("mostPopulatedCity", "inputCountry", "inputYear", MAX ([Country]), MAX([Year]))
MODEL_PERCENTILE(target_expression, predictor_expression(s))
Returns the probability (between 0 and 1) of the expected value being less than or equal to the observed mark, defined by the target expression and other predictors. This is the Posterior Predictive Distribution Function, also known as the Cumulative Distribution Function (CDF).
This function is the inverse of MODEL_QUANTILE. For information on predictive modeling functions, see How Predictive Modeling Functions Work in Tableau.
Example
The following formula returns the quantile of the mark for sum of sales, adjusted for count of orders.
MODEL_PERCENTILE(SUM([Sales]), COUNT([Orders]))
MODEL_QUANTILE(quantile, target_expression, predictor_expression(s))
Returns a target numeric value within the probable range defined by the target expression and other predictors, at a specified quantile. This is the Posterior Predictive Quantile.
This function is the inverse of MODEL_PERCENTILE. For information on predictive modeling functions, see How Predictive Modeling Functions Work in Tableau.
Example
The following formula returns the median (0.5) predicted sum of sales, adjusted for count of orders.
MODEL_QUANTILE(0.5, SUM([Sales]), COUNT([Orders]))
PREVIOUS_VALUE(expression)
Returns the value of this calculation in the previous row. Returns the given expression if the current row is the first row of the partition.
Example
SUM([Profit]) * PREVIOUS_VALUE(1)
computes the running product of SUM(Profit).
RANK(expression, ['asc'  'desc'])
Returns the standard competition rank for the current row in the partition. Identical values are assigned an identical rank. Use the optional 'asc'  'desc'
argument to specify ascending or descending order. The default is descending.
With this function, the set of values (6, 9, 9, 14) would be ranked (4, 2, 2, 1).
Nulls are ignored in ranking functions. They are not numbered and they do not count against the total number of records in percentile rank calculations.
For information on different ranking options, see Rank calculation.
Example
The following image shows the effect of the various ranking functions (RANK, RANK_DENSE, RANK_MODIFIED, RANK_PERCENTILE, and RANK_UNIQUE) on a set of values. The data set contains information on 14 students (StudentA through StudentN); the Age column shows the current age of each student (all students are between 17 and 20 years of age). The remaining columns show the effect of each rank function on the set of age values, always assuming the default order (ascending or descending) for the function.
RANK_DENSE(expression, ['asc'  'desc'])
Returns the dense rank for the current row in the partition. Identical values are assigned an identical rank, but no gaps are inserted into the number sequence. Use the optional 'asc'  'desc'
argument to specify ascending or descending order. The default is descending.
With this function, the set of values (6, 9, 9, 14) would be ranked (3, 2, 2, 1).
Nulls are ignored in ranking functions. They are not numbered and they do not count against the total number of records in percentile rank calculations.
For information on different ranking options, see Rank calculation.
RANK_MODIFIED(expression, ['asc'  'desc'])
Returns the modified competition rank for the current row in the partition. Identical values are assigned an identical rank. Use the optional 'asc'  'desc'
argument to specify ascending or descending order. The default is descending.
With this function, the set of values (6, 9, 9, 14) would be ranked (4, 3, 3, 1).
Nulls are ignored in ranking functions. They are not numbered and they do not count against the total number of records in percentile rank calculations.
For information on different ranking options, see Rank calculation.
RANK_PERCENTILE(expression, ['asc'  'desc'])
Returns the percentile rank for the current row in the partition. Use the optional 'asc'  'desc'
argument to specify ascending or descending order. The default is ascending.
With this function, the set of values (6, 9, 9, 14) would be ranked (0.00, 0.67, 0.67, 1.00).
Nulls are ignored in ranking functions. They are not numbered and they do not count against the total number of records in percentile rank calculations.
For information on different ranking options, see Rank calculation.
RANK_UNIQUE(expression, ['asc'  'desc'])
Returns the unique rank for the current row in the partition. Identical values are assigned different ranks. Use the optional 'asc'  'desc'
argument to specify ascending or descending order. The default is descending.
With this function, the set of values (6, 9, 9, 14) would be ranked (4, 2, 3, 1).
Nulls are ignored in ranking functions. They are not numbered and they do not count against the total number of records in percentile rank calculations.
For information on different ranking options, see Rank calculation.
RUNNING_AVG(expression)
Returns the running average of the given expression, from the first row in the partition to the current row.
The view below shows quarterly
sales. When RUNNING_AVG(SUM([Sales])
is computed within the Date
partition, the result is a running average of the sales values for
each quarter.
Example
RUNNING_AVG(SUM([Profit]))
computes the running average of SUM(Profit).
RUNNING_COUNT(expression)
Returns the running count of the given expression, from the first row in the partition to the current row.
Example
RUNNING_COUNT(SUM([Profit]))
computes the running count of SUM(Profit).
RUNNING_MAX(expression)
Returns the running maximum of the given expression, from the first row in the partition to the current row.
Example
RUNNING_MAX(SUM([Profit]))
computes the running maximum of SUM(Profit).
RUNNING_MIN(expression)
Returns the running minimum of the given expression, from the first row in the partition to the current row.
Example
RUNNING_MIN(SUM([Profit]))
computes the running minimum of SUM(Profit).
RUNNING_SUM(expression)
Returns the running sum of the given expression, from the first row in the partition to the current row.
Example
RUNNING_SUM(SUM([Profit]))
computes the running sum of SUM(Profit)
SIZE()
Returns the number of rows in the partition. For example, the view below shows quarterly sales. Within the Date partition, there are seven rows so the Size() of the Date partition is 7.
Example
SIZE() = 5
when the current partition contains five rows.
SCRIPT_BOOL
Returns a Boolean result from the specified expression. The expression is passed directly to a running analytics extension service instance.
In R expressions, use .argn (with a leading period) to reference parameters (.arg1, .arg2, etc.).
In Python expressions, use _argn (with a leading underscore).
Examples
In this R example, .arg1 is equal to SUM([Profit]):
SCRIPT_BOOL("is.finite(.arg1)", SUM([Profit]))
The next example returns True for store IDs in Washington state, and False otherwise. This example could be the definition for a calculated field titled IsStoreInWA.
SCRIPT_BOOL('grepl(".*_WA", .arg1, perl=TRUE)',ATTR([Store ID]))
A command for Python would take this form:
SCRIPT_BOOL("return map(lambda x : x > 0, _arg1)", SUM([Profit]))
SCRIPT_INT
Returns an integer result from the specified expression. The expression is passed directly to a running analytics extension service instance.
In R expressions, use .argn (with a leading period) to reference parameters (.arg1, .arg2, etc.)
In Python expressions, use _argn (with a leading underscore).
Examples
In this R example, .arg1 is equal to SUM([Profit]):
SCRIPT_INT("is.finite(.arg1)", SUM([Profit]))
In the next example, kmeans clustering is used to create three clusters:
SCRIPT_INT('result < kmeans(data.frame(.arg1,.arg2,.arg3,.arg4), 3);result$cluster;', SUM([Petal length]), SUM([Petal width]),SUM([Sepal length]),SUM([Sepal width]))
A command for Python would take this form:
SCRIPT_INT("return map(lambda x : int(x * 5), _arg1)", SUM([Profit]))
SCRIPT_REAL
Returns a real result from the specified expression. The expression is passed directly to a running analytics extension service instance. In
R expressions, use .argn (with a leading period) to reference parameters (.arg1, .arg2, etc.)
In Python expressions, use _argn (with a leading underscore).
Examples
In this R example, .arg1 is equal to SUM([Profit]):
SCRIPT_REAL("is.finite(.arg1)", SUM([Profit]))
The next example converts temperature values from Celsius to Fahrenheit.
SCRIPT_REAL('library(udunits2);ud.convert(.arg1, "celsius", "degree_fahrenheit")',AVG([Temperature]))
A command for Python would take this form:
SCRIPT_REAL("return map(lambda x : x * 0.5, _arg1)", SUM([Profit]))
SCRIPT_STR
Returns a string result from the specified expression. The expression is passed directly to a running analytics extension service instance.
In R expressions, use .argn (with a leading period) to reference parameters (.arg1, .arg2, etc.)
In Python expressions, use _argn (with a leading underscore).
Examples
In this R example, .arg1 is equal to SUM([Profit]):
SCRIPT_STR("is.finite(.arg1)", SUM([Profit]))
The next example extracts a state abbreviation from a more complicated string (in the original form 13XSL_CA, A13_WA):
SCRIPT_STR('gsub(".*_", "", .arg1)',ATTR([Store ID]))
A command for Python would take this form:
SCRIPT_STR("return map(lambda x : x[:2], _arg1)", ATTR([Region]))
TOTAL(expression)
Returns the total for the given expression in a table calculation partition.
Example
Assume you are starting with this view:
You open the calculation editor and create a new field which you name Totality:
You then drop Totality on Text, to replace SUM(Sales). Your view changes such that it sums values based on the default Compute Using value:
This raises the question, What is the default Compute Using value? If you rightclick (Controlclick on a Mac) Totality in the Data pane and choose Edit, there is now an additional bit of information available:
The default Compute Using value is Table (Across). The result is that Totality is summing the values across each row of your table. Thus, the value that you see across each row is the sum of the values from the original version of the table.
The values in the 2011/Q1 row in the original table were $8601, $6579, $44262, and $15006. The values in the table after Totality replaces SUM(Sales) are all $74,448, which is the sum of the four original values.
Notice the triangle next to Totality after you drop it on Text:
This indicates that this field is using a table calculation. You can rightclick the field and choose Edit Table Calculation to redirect your function to a different Compute Using value. For example, you could set it to Table (Down). In that case, your table would look like this:
WINDOW_AVG(expression, [start, end])
Returns the average of the expression within the window. The window is defined by means of offsets from the current row. Use FIRST()+n and LAST()n for offsets from the first or last row in the partition. If the start and end are omitted, the entire partition is used.
For example, the view below shows quarterly sales. A window average within the Date partition returns the average sales across all dates.
Example
WINDOW_AVG(SUM([Profit]), FIRST()+1, 0)
computes the average of
SUM(Profit) from the second row to the current row.
WINDOW_CORR(expression1, expression2, [start, end])
Returns the Pearson correlation coefficient of two expressions within the window. The window is defined as offsets from the current row. Use FIRST()+n and LAST()n for offsets from the first or last row in the partition. If start and end are omitted, the entire partition is used.
The Pearson correlation measures the linear relationship between two variables. Results range from 1 to +1 inclusive, where 1 denotes an exact positive linear relationship, as when a positive change in one variable implies a positive change of corresponding magnitude in the other, 0 denotes no linear relationship between the variance, and −1 is an exact negative relationship.
There is an equivalent aggregation fuction: CORR. See Tableau Functions (Alphabetical)(Link opens in a new window).
Example
The following formula returns the Pearson correlation of SUM(Profit) and SUM(Sales) from the five previous rows to the current row.
WINDOW_CORR(SUM[Profit]), SUM([Sales]), 5, 0)
WINDOW_COUNT(expression, [start, end])
Returns the count of the expression within the window. The window is defined by means of offsets from the current row. Use FIRST()+n and LAST()n for offsets from the first or last row in the partition. If the start and end are omitted, the entire partition is used.
Example
WINDOW_COUNT(SUM([Profit]), FIRST()+1, 0)
computes the count of SUM(Profit)
from the second row to the current row
WINDOW_COVAR(expression1, expression2, [start, end])
Returns the sample covariance of two expressions within the window. The window is defined as offsets from the current row. Use FIRST()+n and LAST()n for offsets from the first or last row in the partition. If the start and end arguments are omitted, the window is the entire partition.
Sample covariance uses the number of nonnull data points n  1 to normalize the covariance calculation, rather than n, which is used by the population covariance (with the WINDOW_COVARP function). Sample covariance is the appropriate choice when the data is a random sample that is being used to estimate the covariance for a larger population.
There is an equivalent aggregation fuction: COVAR. See Tableau Functions (Alphabetical)(Link opens in a new window).
Example
The following formula returns the sample covariance of SUM(Profit) and SUM(Sales) from the two previous rows to the current row.
WINDOW_COVAR(SUM([Profit]), SUM([Sales]), 2, 0)
WINDOW_COVARP(expression1, expression2, [start, end])
Returns the population covariance of two expressions within the window. The window is defined as offsets from the current row. Use FIRST()+n and LAST()n for offsets from the first or last row in the partition. If start and end are omitted, the entire partition is used.
Population covariance is sample covariance multiplied by (n1)/n, where n is the total number of nonnull data points. Population covariance is the appropriate choice when there is data available for all items of interest as opposed to when there is only a random subset of items, in which case sample covariance (with the WINDOW_COVAR function) is appropriate.
There is an equivalent aggregation fuction: COVARP. Tableau Functions (Alphabetical)(Link opens in a new window).
Example
The following formula returns the population covariance of SUM(Profit) and SUM(Sales) from the two previous rows to the current row.
WINDOW_COVARP(SUM([Profit]), SUM([Sales]), 2, 0)
WINDOW_MEDIAN(expression, [start, end])
Returns the median of the expression within the window. The window is defined by means of offsets from the current row. Use FIRST()+n and LAST()n for offsets from the first or last row in the partition. If the start and end are omitted, the entire partition is used.
For example, the view below shows quarterly profit. A window median within the Date partition returns the median profit across all dates.
Example
WINDOW_MEDIAN(SUM([Profit]), FIRST()+1, 0)
computes the median
of SUM(Profit) from the second row to the current row.
WINDOW_MAX(expression, [start, end])
Returns the maximum of the expression within the window. The window is defined by means of offsets from the current row. Use FIRST()+n and LAST()n for offsets from the first or last row in the partition. If the start and end are omitted, the entire partition is used.
For example, the view below shows quarterly sales. A window maximum within the Date partition returns the maximum sales across all dates.
Example
WINDOW_MAX(SUM([Profit]), FIRST()+1, 0)
computes the maximum of
SUM(Profit) from the second row to the current row.
WINDOW_MIN(expression, [start, end])
Returns the minimum of the expression within the window. The window is defined by means of offsets from the current row. Use FIRST()+n and LAST()n for offsets from the first or last row in the partition. If the start and end are omitted, the entire partition is used.
For example, the view below shows quarterly sales. A window minimum within the Date partition returns the minimum sales across all dates.
Example
WINDOW_MIN(SUM([Profit]), FIRST()+1, 0)
computes the minimum of
SUM(Profit) from the second row to the current row.
WINDOW_PERCENTILE(expression, number, [start, end])
Returns the value corresponding to the specified percentile within the window. The window is defined by means of offsets from the current row. Use FIRST()+n and LAST()n for offsets from the first or last row in the partition. If the start and end are omitted, the entire partition is used.
Example
WINDOW_PERCENTILE(SUM([Profit]), 0.75, 2, 0)
returns the 75th percentile for SUM(Profit) from the two previous rows to the current row.
WINDOW_STDEV(expression, [start, end])
Returns the sample standard deviation of the expression within the window. The window is defined by means of offsets from the current row. Use FIRST()+n and LAST()n for offsets from the first or last row in the partition. If the start and end are omitted, the entire partition is used.
Example
WINDOW_STDEV(SUM([Profit]), FIRST()+1, 0)
computes the standard deviation of SUM(Profit)
from the second row to the current row.
WINDOW_STDEVP(expression, [start, end])
Returns the biased standard deviation of the expression within the window. The window is defined by means of offsets from the current row. Use FIRST()+n and LAST()n for offsets from the first or last row in the partition. If the start and end are omitted, the entire partition is used.
Example
WINDOW_STDEVP(SUM([Profit]), FIRST()+1, 0)
computes the standard deviation of SUM(Profit)
from the second row to the current row.
WINDOW_SUM(expression, [start, end])
Returns the sum of the expression within the window. The window is defined by means of offsets from the current row. Use FIRST()+n and LAST()n for offsets from the first or last row in the partition. If the start and end are omitted, the entire partition is used.
For example, the view below shows quarterly sales. A window sum computed within the Date partition returns the summation of sales across all quarters.
Example
WINDOW_SUM(SUM([Profit]), FIRST()+1, 0)
computes the sum of SUM(Profit) from the second row to
the current row.
WINDOW_VAR(expression, [start, end])
Returns the sample variance of the expression within the window. The window is defined by means of offsets from the current row. Use FIRST()+n and LAST()n for offsets from the first or last row in the partition. If the start and end are omitted, the entire partition is used.
Example
WINDOW_VAR((SUM([Profit])), FIRST()+1, 0)
computes the variance of SUM(Profit)
from the second row to the current row.
WINDOW_VARP(expression, [start, end])
Returns the biased variance of the expression within the window. The window is defined by means of offsets from the current row. Use FIRST()+n and LAST()n for offsets from the first or last row in the partition. If the start and end are omitted, the entire partition is used.
Example
WINDOW_VARP(SUM([Profit]), FIRST()+1, 0)
computes the variance of SUM(Profit)
from the second row to the current row.
These RAWSQL passthrough functions can be used to send SQL expressions directly to the database, without first being interpreted by Tableau. If you have custom database functions that Tableau doesn’t know about, you can use these passthrough functions to call these custom functions.
Your database usually will not understand the field names that are shown in Tableau. Because Tableau does not interpret the SQL expressions you include in the passthrough functions, using the Tableau field names in your expression may cause errors. You can use a substitution syntax to insert the correct field name or expression for a Tableau calculation into passthrough SQL. For example, if you had a function that computed the median of a set of values, you could call that function on the Tableau column [Sales] like this:
RAWSQLAGG_REAL(“MEDIAN(%1)”, [Sales])
Because Tableau does not interpret the expression, you must define the aggregation. You can use the RAWSQLAGG functions described below when you are using aggregated expressions.
RAWSQL passthrough functions may not work with extracts or published data sources if they contain relationships.
RAWSQL Functions
The following RAWSQL functions are available in Tableau.
RAWSQL_BOOL(“sql_expr”, [arg1], …[argN])
Returns a Boolean result from a given SQL expression. The SQL expression is passed directly to the underlying database. Use %n in the SQL expression as a substitution syntax for database values.
Example
In the example, %1 is equal to [Sales] and %2 is equal to [Profit].
RAWSQL_BOOL(“IIF( %1 > %2, True, False)”, [Sales], [Profit])
RAWSQL_DATE(“sql_expr”, [arg1], …[argN])
Returns a Date result from a given SQL expression. The SQL expression is passed directly to the underlying database. Use %n in the SQL expression as a substitution syntax for database values.
Example
In this example, %1 is equal to [Order Date].
RAWSQL_DATE(“%1”, [Order
Date])
RAWSQL_DATETIME(“sql_expr”, [arg1], …[argN])
Returns a Date and Time result from a given SQL expression. The SQL expression is passed directly to the underlying database. Use %n in the SQL expression as a substitution syntax for database values. In this example, %1 is equal to [Delivery Date].
Example
RAWSQL_DATETIME(“MIN(%1)”, [Delivery Date])
RAWSQL_INT(“sql_expr”, [arg1], …[argN])
Returns an integer result from a given SQL expression. The SQL expression is passed directly to the underlying database. Use %n in the SQL expression as a substitution syntax for database values. In this example, %1 is equal to [Sales].
Example
RAWSQL_INT(“500
+ %1”, [Sales])
RAWSQL_REAL(“sql_expr”, [arg1], …[argN])
Returns a numeric result from a given SQL expression that is passed directly to the underlying database. Use %n in the SQL expression as a substitution syntax for database values. In this example, %1 is equal to [Sales]
Example
RAWSQL_REAL(“123.98 * %1”, [Sales])
RAWSQL_SPATIAL
Returns a Spatial from a given SQL expression that is passed directly to the underlying data source. Use %n in the SQL expression as a substitution syntax for database values.
Example
In this example, %1 is equal to [Geometry].
RAWSQL_SPATIAL("%1", [Geometry])
RAWSQL_STR(“sql_expr”, [arg1], …[argN])
Returns a string from a given SQL expression that is passed directly to the underlying database. Use %n in the SQL expression as a substitution syntax for database values. In this example, %1 is equal to [Customer Name].
Example
RAWSQL_STR(“%1”, [Customer Name])
RAWSQLAGG_BOOL(“sql_expr”, [arg1], …[argN])
Returns a Boolean result from a given aggregate SQL expression. The SQL expression is passed directly to the underlying database. Use %n in the SQL expression as a substitution syntax for database values.
Example
In the example, %1 is equal to [Sales] and %2 is equal to [Profit].
RAWSQLAGG_BOOL(“SUM( %1) >SUM( %2)”, [Sales], [Profit])
RAWSQLAGG_DATE(“sql_expr”, [arg1], …[argN])
Returns a Date result from a given aggregate SQL expression. The SQL expression is passed directly to the underlying database. Use %n in the SQL expression as a substitution syntax for database values. In this example, %1 is equal to [Order Date].
Example
RAWSQLAGG_DATE(“MAX(%1)”,
[Order Date])
RAWSQLAGG_DATETIME(“sql_expr”, [arg1], …[argN])
Returns a Date and Time result from a given aggregate SQL expression. The SQL expression is passed directly to the underlying database. Use %n in the SQL expression as a substitution syntax for database values. In this example, %1 is equal to [Delivery Date].
Example
RAWSQLAGG_DATETIME(“MIN(%1)”, [Delivery Date])
RAWSQLAGG_INT(“sql_expr”, [arg1,] …[argN])
Returns an integer result from a given aggregate SQL expression. The SQL expression is passed directly to the underlying database. Use %n in the SQL expression as a substitution syntax for database values. In this example, %1 is equal to [Sales].
Example
RAWSQLAGG_INT(“500
+ SUM(%1)”, [Sales])
RAWSQLAGG_REAL(“sql_expr”, [arg1,] …[argN])
Returns a numeric result from a given aggregate SQL expression that is passed directly to the underlying database. Use %n in the SQL expression as a substitution syntax for database values. In this example, %1 is equal to [Sales]
Example
RAWSQLAGG_REAL(“SUM( %1)”, [Sales])
RAWSQLAGG_STR(“sql_expr”, [arg1,] …[argN])
Returns a string from a given aggregate SQL expression that is passed directly to the underlying database. Use %n in the SQL expression as a substitution syntax for database values. In this example, %1 is equal to [Discount].
Example
RAWSQLAGG_STR(“AVG(%1)”,
[Discount])
Spatial functions allow you to perform advanced spatial analysis and combine spatial files with data in other formats like text files or spreadsheets.
Function 
Syntax 
Description 
AREA  AREA(Geometry, "units") 
Returns the total surface area of a spatial polygon. Supported unit names: meters ("meters," "metres" "m"), kilometers ("kilometers," "kilometres," "km"), miles ("miles" or "mi"), feet ("feet," "ft"). 
BUFFER  BUFFER(Spatial Point, distance, "units") 
Returns distance measurement between two points in a specified unit. Supported unit names: meters ("meters," "metres" "m"), kilometers ("kilometers," "kilometres," "km"), miles ("miles" or "mi"), feet ("feet," "ft"). This function can only be created with a live connection and will continue to work when a data source is converted to an extract. 
DISTANCE 
DISTANCE(<geometry1>,<geometry2>,"<units>")

Returns distance measurement between two points in a specified unit. Supported unit names: meters ("meters," "metres" "m), kilometers ("kilometers," "kilometres," "km"), miles ("miles" or "miles"), feet ("feet," "ft"). This function can only be created with a live connection and will continue to work when a data source is converted to an extract. Example:

MAKELINE 
MAKELINE(<geometry1>,<geometry2>)

Generates a line mark between two points; useful for building origindestination maps. Examples:

MAKEPOINT 
MAKEPOINT(<latitude>, <longitude>)

Converts data from latitude and longitude columns into spatial objects. You can use MAKEPOINT to spatiallyenable a data source so that it can be joined with a spatial file using a spatial join. For more information, see Join Spatial Files in Tableau . To use MAKEPOINT, your data must contain latitude and longitude coordinates. Example:

MAKEPOINT(X,Y, SRID) 

Converts data from projected geographic coordinates into spatial objects. SRID is a spatial reference identifier that uses ESPG reference system codes to specify coordinate systems. If SRID is not specified, WGS84 is assumed and parameters are treated as latitude/longitude in degrees. This function can only be created with a live connection and will continue to work when a data source is converted to an extract. Example:

Regular Expressions
REGEXP_REPLACE(string, pattern, replacement)
Returns a copy of the given string where the regular expression pattern is replaced by the replacement string. This function is available for Text File, Hadoop Hive, Google BigQuery, PostgreSQL, Tableau Data Extract, Microsoft Excel, Salesforce, Vertica, Pivotal Greenplum, Teradata (version 14.1 and above), Snowflake, and Oracle data sources.
For Tableau data extracts, the pattern and the replacement must be constants.
For information on regular expression syntax, see your data source's documentation. For Tableau extracts, regular expression syntax conforms to the standards of the ICU (International Components for Unicode), an open source project of mature C/C++ and Java libraries for Unicode support, software internationalization, and software globalization. See the Regular Expressions(Link opens in a new window) page in the online ICU User Guide.
Example
REGEXP_REPLACE('abc 123', '\s', '') = 'abc123'
REGEXP_MATCH(string, pattern)
Returns true if a substring of the specified string matches the regular expression pattern. This function is available for Text File, Google BigQuery, PostgreSQL, Tableau Data Extract, Microsoft Excel, Salesforce, Vertica, Pivotal Greenplum, Teradata (version 14.1 and above), Impala 2.3.0 (through Cloudera Hadoop data sources), Snowflake, and Oracle data sources.
For Tableau data extracts, the pattern must be a constant.
For information on regular expression syntax, see your data source's documentation. For Tableau extracts, regular expression syntax conforms to the standards of the ICU (International Components for Unicode), an open source project of mature C/C++ and Java libraries for Unicode support, software internationalization, and software globalization. See the Regular Expressions(Link opens in a new window) page in the online ICU User Guide.
Example
REGEXP_MATCH('([1234].[The.Market])','\[\s*(\w*\.)(\w*\s*\])')=true
REGEXP_EXTRACT(string, pattern)
Returns the portion of the string that matches the regular expression pattern. This function is available for Text File, Hadoop Hive, Google BigQuery, PostgreSQL, Tableau Data Extract, Microsoft Excel, Salesforce, Vertica, Pivotal Greenplum, Teradata (version 14.1 and above), Snowflake, and Oracle data sources.
For Tableau data extracts, the pattern must be a constant.
For information on regular expression syntax, see your data source's documentation. For Tableau extracts, regular expression syntax conforms to the standards of the ICU (International Components for Unicode), an open source project of mature C/C++ and Java libraries for Unicode support, software internationalization, and software globalization. See the Regular Expressions(Link opens in a new window) page in the online ICU User Guide.
Example
REGEXP_EXTRACT('abc 123', '[az]+\s+(\d+)') = '123'
REGEXP_EXTRACT_NTH(string, pattern, index)
Returns the portion of the string that matches the regular expression pattern. The substring is matched to the nth capturing group, where n is the given index. If index is 0, the entire string is returned. This function is available for Text File, PostgreSQL, Tableau Data Extract, Microsoft Excel, Salesforce, Vertica, Pivotal Greenplum, Teradata (version 14.1 and above), and Oracle data sources.
For Tableau data extracts, the pattern must be a constant.
For information on regular expression syntax, see your data source's documentation. For Tableau extracts, regular expression syntax conforms to the standards of the ICU (International Components for Unicode), an open source project of mature C/C++ and Java libraries for Unicode support, software internationalization, and software globalization. See the Regular Expressions(Link opens in a new window) page in the online ICU User Guide.
Example
REGEXP_EXTRACT_NTH('abc 123', '([az]+)\s+(\d+)', 2) = '123'
Hadoop Hive Specific Functions
Note: Only the PARSE_URL and PARSE_URL_QUERY functions are available for Cloudera Impala data sources.
GET_JSON_OBJECT(JSON string, JSON path)
Returns the JSON object within the JSON string based on the JSON path.
PARSE_URL(string, url_part)
Returns a component of the given URL string where the component is defined by url_part. Valid url_part values include: 'HOST', 'PATH', 'QUERY', 'REF', 'PROTOCOL', 'AUTHORITY', 'FILE' and 'USERINFO'.
Example
PARSE_URL('http://www.tableau.com', 'HOST') = 'www.tableau.com'
PARSE_URL_QUERY(string, key)
Returns the value of the specified query parameter in the given URL string. The query parameter is defined by the key.
Example
PARSE_URL_QUERY('http://www.tableau.com?page=1&cat=4', 'page') = '1'
XPATH_BOOLEAN(XML string, XPath expression string)
Returns true if the XPath expression matches a node or evaluates to true.
Example
XPATH_BOOLEAN('<values> <value id="0">1</value><value id="1">5</value>', 'values/value[@id="1"] = 5') = true
XPATH_DOUBLE(XML string, XPath expression string)
Returns the floatingpoint value of the XPath expression.
Example
XPATH_DOUBLE('<values><value>1.0</value><value>5.5</value> </values>', 'sum(value/*)') = 6.5
XPATH_FLOAT(XML string, XPath expression string)
Returns the floatingpoint value of the XPath expression.
Example
XPATH_FLOAT('<values><value>1.0</value><value>5.5</value> </values>','sum(value/*)') = 6.5
XPATH_INT(XML string, XPath expression string)
Returns the numerical value of the XPath expression, or zero if the XPath expression cannot evaluate to a number.
Example
XPATH_INT('<values><value>1</value><value>5</value> </values>','sum(value/*)') = 6
XPATH_LONG(XML string, XPath expression string)
Returns the numerical value of the XPath expression, or zero if the XPath expression cannot evaluate to a number.
Example
XPATH_LONG('<values><value>1</value><value>5</value> </values>','sum(value/*)') = 6
XPATH_SHORT(XML string, XPath expression string)
Returns the numerical value of the XPath expression, or zero if the XPath expression cannot evaluate to a number.
Example
XPATH_SHORT('<values><value>1</value><value>5</value> </values>','sum(value/*)') = 6
XPATH_STRING(XML string, XPath expression string)
Returns the text of the first matching node.
Example
XPATH_STRING('<sites ><url domain="org">http://www.w3.org</url> <url domain="com">http://www.tableau.com</url></sites>', 'sites/url[@domain="com"]') = 'http://www.tableau.com'
Google BigQuery Specific Functions
DOMAIN(string_url)
Given a URL string, returns the domain as a string.
Example
DOMAIN('http://www.google.com:80/index.html') = 'google.com'
GROUP_CONCAT(expression)
Concatenates values from each record into a single commadelimited string. This function acts like a SUM() for strings.
Example
GROUP_CONCAT(Region) = "Central,East,West"
HOST(string_url)
Given a URL string, returns the host name as a string.
Example
HOST('http://www.google.com:80/index.html') = 'www.google.com:80'
LOG2(number)
Returns the logarithm base 2 of a number.
Example
LOG2(16) = '4.00'
LTRIM_THIS(string, string)
Returns the first string with any leading occurrence of the second string removed.
Example
LTRIM_THIS('[Sales]','[') = 'Sales]'
RTRIM_THIS(string, string)
Returns the first string with any trailing occurrence of the second string removed.
Example
RTRIM_THIS('[Market]',']') = '[Market'
TIMESTAMP_TO_USEC(expression)
Converts a TIMESTAMP data type to a UNIX timestamp in microseconds.
Example
TIMESTAMP_TO_USEC(#20121001 01:02:03#)=1349053323000000
USEC_TO_TIMESTAMP(expression)
Converts a UNIX timestamp in microsseconds to a TIMESTAMP data type.
Example
USEC_TO_TIMESTAMP(1349053323000000) = #20121001 01:02:03#
TLD(string_url)
Given a URL string, returns the top level domain plus any country/region domain in the URL.
Example
TLD('http://www.google.com:80/index.html') = '.com'
TLD('http://www.google.co.uk:80/index.html') = '.co.uk'
Want to learn more about functions?
Read the functions topics(Link opens in a new window).
See also
Tableau Functions (Alphabetical)(Link opens in a new window)