Supported Functions
Several categories of functions are supported for calculated fields, including aggregate
functions, conditional functions, date functions, numeric functions, mathematical
functions, string functions, and table calculations.
Aggregate Functions
Aggregate functions return values grouped by the chosen dimension or dimensions. For each aggregation, there is also a conditional aggregation that performs the same type of aggregation based on a condition.
avgaverages the set of numbers in the specified measure, grouped by the chosen dimension or dimensions.avgIfcalculates the average based on a conditional statement.countcalculates the number of values in a dimension or measure, grouped by the chosen dimension or dimensions.countIfcalculates the count based on a conditional statement.distinct_countcalculates the number of distinct values in a dimension or measure, grouped by the chosen dimension or dimensions.distinct_countIfcalculates the distinct count based on a conditional statement.maxreturns the maximum value of the specified measure, grouped by the chosen dimension or dimensions.maxIfcalculates the maximum based on a conditional statement.medianreturns the median value of the specified measure, grouped by the chosen dimension or dimensions.medianIfcalculates the median based on a conditional statement.minreturns the minimum value of the specified measure, grouped by the chosen dimension or dimensions.minIfcalculates the minimum based on a conditional statement.percentile(alias ofpercentileDisc) computes the nth percentile of the specified measure, grouped by the chosen dimension or dimensions.percentileContcalculates the nth percentile based on a continuous distribution of the numbers of the specified measure, grouped by the chosen dimension or dimensions.percentileDisc(percentile) calculates the nth percentile based on the actual numbers of the specified measure, grouped by the chosen dimension or dimensions.periodToDateAvgaverages the set of numbers in the specified measure for a given time granularity, such as a quarter, up to a point in time.periodToDateCountcalculates the number of values in a dimension or measure for a given time granularity, such as a quarter, up to a point in time including duplicates.periodToDateMaxreturns the maximum value of the specified measure for a given time granularity, such as a quarter, up to a point in time.periodToDateMedianreturns the median value of the specified measure for a given time granularity, such as a quarter, up to a point in time.periodToDateMinreturns the minimum value of the specified measure or date for a given time granularity, such as a quarter, up to a point in time.periodToDatePercentilecalculates the percentile based on the actual numbers in the specified measure for a given time granularity, such as a quarter, up to a point in time.periodToDatePercentileContcalculates the percentile based on a continuous distribution of the numbers in the specified measure for a given time granularity, such as a quarter, up to a point in time.periodToDateStDevcalculates the standard deviation of the set of numbers in the specified measure for a given time granularity, such as a quarter, up to a point in time based on a sample.periodToDateStDevPcalculates the population standard deviation of the set of numbers in the specified measure for a given time granularity, such as a quarter, up to a point in time based on a sample.periodToDateSumadds the set of numbers in the specified measure for a given time granularity, such as a quarter, up to a point in time.periodToDateVarcalculates the sample variance of the set of numbers in the specified measure for a given time granularity, such as a quarter, up to a point in time.periodToDateVarPcalculates the population variance of the set of numbers in the specified measure for a given time granularity, such as a quarter, up to a point in time.stdevcalculates the standard deviation of the set of numbers in the specified measure, grouped by the chosen dimension or dimensions, based on a sample.stdevIfcalculates the sample standard deviation based on a conditional statement.stdevpcalculates the standard deviation of the set of numbers in the specified measure, grouped by the chosen dimension or dimensions, based on a biased population.stdevpIfcalculates the population deviation based on a conditional statement.sumadds the set of numbers in the specified measure, grouped by the chosen dimension or dimensions.sumIfcalculates the sum based on a conditional statement.varcalculates the variance of the set of numbers in the specified measure, grouped by the chosen dimension or dimensions, based on a sample.varIfcalculates the sample variance based on a conditional statement.varpcalculates the variance of the set of numbers in the specified measure, grouped by the chosen dimension or dimensions, based on a biased population.varpIfcalculates the population variance based on a conditional statement.
When a calculated field formula contains an aggregation, it becomes a custom aggregation. To make sure that the data is displayed accurately, these rules apply to custom aggregations:
- Custom aggregations cannot contain nested aggregate functions, as in the formula
sum(avg(x)/avg(y)). However, you can nest nonaggregated functions inside or outside aggregate functions, as in the formulasceil(avg(x))oravg(ceil(x)). - Custom aggregations cannot contain both aggregated and nonaggregated fields, in any combination.
- Filter groups cannot contain both aggregated and nonaggregated fields.
- You cannot convert custom aggregations to a dimension or add them to a field well as a dimension.
- In pivot tables, you cannot add custom aggregations to table calculations.
- Scatter plots with custom aggregations must have at least one dimension in the Group/Color field well.
Conditional Functions
coalescereturns the value of the first argument that is not null.ifelseevaluates a set ofif, thenexpression pairings, and returns the value of thethenargument for the firstifargument that evaluates to TRUE.inevaluates an expression to see if it is in a given list of values.isNotNullevaluates an expression to see if it is not null.isNullevaluates an expression to see if it is null. If the expression is null, the function returns TRUE, and otherwise it returns false.notInevaluates an expression to see if it is not in a given list of values.nullIfcompares two expressions. If they are equal, the function returns null. If they are not equal, the function returns the first expression.switchreturns an expression that matches the first label equal to the condition expression.
Date Functions
addDateTimeadds or subtracts a unit of time from the date or time provided.addWorkDaysadds or subtracts the given number of work days from the date or time provided.dateDiffreturns the difference in days between two date fields.epochDateconverts an epoch date into a standard date.extractreturns a specified portion of a date value.formatDateformats a date using a pattern that you specify.isWorkDayreturns TRUE if a given date-time value is a work or business day.netWorkDaysreturns the number of working days between the provided two date values.nowreturns the current date and time.truncDatereturns a date value that represents a specified portion of a date.
Numeric Functions
ceilrounds a decimal value to the next highest integer.decimalToIntconverts a decimal value to an integer.floordecrements a decimal value to the next lowest integer.intToDecimalconverts an integer value to a decimal.roundrounds a decimal value to the closest integer or, if scale is specified, to the closest decimal place.
Mathematical Functions
mod(number, divisor)finds the remainder after dividing a number by a divisor.log(expression)returns the base 10 logarithm of a given expression.ln(expression)returns the natural logarithm of a given expression.abs(expression)returns the absolute value of a given expression.sqrt(expression)returns the square root of a given expression.exp(expression)returns the base of the natural logarithm (e) raised to the power of a given expression.
String Functions
concatconcatenates two or more strings.containschecks if an expression contains a substring.endsWithchecks if the expression ends with the substring specified.leftreturns the specified number of leftmost characters from a string.locatelocates a substring within another string, and returns the number of characters before the substring.ltrimremoves the preceding blank space from a string.parseDateparses a string to determine if it contains a date value and returns the date if it finds it.parseDecimalparses a string to determine if it contains a decimal value.parseIntparses a string to determine if it contains an integer value.replacereplaces part of a string with a new string.rightreturns the specified number of rightmost characters from a string.rtrimremoves the following blank space from a string.splitsplits a string into an array of substrings, based on a delimiter that you choose, and returns the item specified by the position.startsWithchecks if the expression starts with the substring specified.strlenreturns the number of characters in a string.substringreturns the specified number of characters in a string, starting at the specified location.toStringformats the input expression as a string.trimremoves both the preceding and following blank space from a string.