# Function list

Data Studio provides a number of powerful functions that can be used inside of calculated field formulas.

More information on each function, including examples, is available in the formula editor. This help will appear as you begin to type your formula.
TypeNameDescriptionSyntax
Aggregation AVG Returns the average of all values of X.
Learn more.
` AVG(X) `
Aggregation COUNT Returns the number of values of X.
Learn more.
` COUNT(X) `
Aggregation COUNT_DISTINCT Returns the number of unique values of X.
Learn more.
` COUNT_DISTINCT(X) `
Aggregation MAX Returns the maximum value of X.
Learn more.
` MAX(X) `
Aggregation MEDIAN Returns the median of all values of X.
Learn more.
`MEDIAN(X)`
Aggregation MIN Returns the minimum value of X.
Learn more.
` MIN(X) `
Aggregation PERCENTILE Returns the percentile rank N of field X.
Learn more.
`PERCENTILE(X,N) `
Aggregation STDDEV Returns the standard deviation of X.
Learn more.
` STDDEV(X) `
Aggregation SUM Returns the sum of all values of X.
Learn more.
` SUM(X) `
AggregationVARIANCEReturns the variance of X.
Learn more.
`VARIANCE(X)`
Arithmetic ABS Returns the absolute value of number.
Learn more.
` ABS(X) `
Arithmetic ACOS Returns the inverse of the cosine of X.
Learn more.
` ACOS(X) `
Arithmetic ASIN Returns the inverse of the sine of X.
Learn more.
` ASIN(X) `
Arithmetic ATAN Returns the inverse of the tangent of X.
Learn more.
` ATAN(X) `
Arithmetic CEIL Returns the nearest integer greater than X. For example, if the value of X is v, CEIL(X) is greater than or equal to v.
Learn more.
` CEIL(X) `
Arithmetic COS Returns the cosine of X.
Learn more.
` COS(X) `
Arithmetic FLOOR Returns the nearest integer less than X. For example, if the value X is v, FLOOR(X) is equal to or less than v.
Learn more.
` FLOOR(X) `
Arithmetic LOG Returns the logarithm to base 2 of X.
Learn more.
` LOG(X) `
Arithmetic LOG10 Returns the logarithm to base 10 of X.
Learn more.
` LOG10(X) `
Arithmetic NARY_MAX Returns the maximum value of X, Y, [,Z]*. All input arguments must be of the same type: all numbers. At least one input argument must be a field or an expression containing a field.
Learn more.
` NARY_MAX(X, Y [,Z]*) `
Arithmetic NARY_MIN Returns the minimum value of X, Y, [,Z]*. All input arguments must be of the same type, all numbers. At least one input argument must be a field or an expression containing a field.
Learn more.
` NARY_MIN(X, Y [,Z]*) `
Arithmetic POWERReturns result of raising X to the power Y.
Learn more.
` POWER(X, Y) `
Arithmetic ROUND Returns X rounded to Y precision digits.
Learn more.
` ROUND(X, Y) `
Arithmetic SIN Returns the sine of X.
Learn more.
` SIN(X) `
Arithmetic SQRT Returns the square root of X. Note that X must be non-negative.
Learn more.
` SQRT(X) `
Arithmetic TAN Returns the tangent of X.
Learn more.
` TAN(X) `
ConditionalCASEEvaluates the `condition` of each successive WHEN clause and returns the first `result` where the `condition` is true; any remaining WHEN and ELSE clauses are not evaluated. If all conditions are false or NULL, returns `else_result` if present; if not present, returns NULL. Learn more
```
```CASE
WHEN condition THEN result
[WHEN condition THEN result]
[...]
[ELSE else_result]
END``````
ConditionalCASE (Simple)Compares `input_expression` to `expression_to_match` of each successive WHEN clause and returns the first `result` where this comparison returns true. Learn more
```
```CASE input_expression
WHEN expression_to_match THEN result
[WHEN expression_to_match THEN result]
[...]
[ELSE result]
END``````
ConditionalCOALESCEReturns the first non-missing value found in a list of fields.
Learn more.
`COALESCE(field_expression[,field_expression, ...])`
ConditionalIFNULLReturns a result if the input is null, otherwise, returns the input.
Learn more.
`IFNULL(input_expression, null_result)`
ConditionalIFIf `condition` is true, returns `true_result`, else returns `false_result`. `false_result` is not evaluated if `condition` is true. `true_result` is not evaluated if `condition` is false or NULL. Learn more `IF(condition, true_result, false_result) `
ConditionalNULLIFReturns null if the input matches an expression, otherwise returns the input.
Learn more.
`NULLIF(input_expression, expression_to_match)`
Date CURRENT_DATE Returns the current date as of the specified or default timezone.
Learn more.
` CURRENT_DATE([time_zone]) `
Date CURRENT_DATETIME Returns the current date and time as of the specified or default timezone.
Learn more.
` CURRENT_DATETIME([time_zone]) `
Date DATE Constructs a Date field or value from numbers or from a Date & Time field or expression.
Learn more.
`DATE(year, month, day)`
Date DATE_DIFF Returns the difference in days between X and Y (X - Y).
Learn more.
` DATE_DIFF(X, Y) `
Date DATE_FROM_UNIX_DATE Interprets an integer as the number of days since 1970-01-01.
Learn more.
` DATE_FROM_UNIX_DATE(integer) `
Date DATETIME Constructs a Date & Time field or value from numbers.
Learn more.
` DATETIME(year, month, day, hour, minute, second) `
Date DATETIME_ADD Adds a specified time interval to a date.
Learn more.
`DATETIME_ADD(datetime_expression, INTERVAL integer part)`
Date DATETIME_DIFF Returns the number of part boundaries between two dates.
Learn more.
`DATETIME_DIFF(date_expression, date_expression, part)`
Date DATETIME_SUB Subtracts a specified time interval from a date.
Learn more.
``` DATETIME_SUB(datetime_expression, INTERVAL integer part) ```
Date DATETIME_TRUNC Truncates a date to the specified granularity.
Learn more.
` DATETIME_TRUNC(date_expression, part) `
Date DAY Returns the day of a Date or Date & Time.
Learn more.
` Day(date_expression) `
Date EXTRACT Returns part of a Date or Date & Time.
Learn more.
` EXTRACT(part FROM date_expression) `
Date FORMAT_DATETIME Returns a formatted date string.
Learn more.
`FORMAT_DATETIME(format_string, datetime_expression)`
Date HOUR Returns the hour of a date and time.
Learn more.
` HOUR(datetime_expression) `
Date MINUTE Returns the minutes component of a given date and time.
Learn more.
` MINUTE(datetime_expression) `
Date MONTH Returns the month from a Date & Time value.
Learn more.
` MONTH(date_expression)`
Date PARSE_DATE Converts text to a date.
Learn more.
`PARSE_DATE(format_string, text)`
Date PARSE_DATETIME Converts text to a date with time.
Learn more.
`PARSE_DATETIME(format_string, text)`
Date QUARTER Returns the quarter of the year for a given date.
Learn more.
` QUARTER(date_expression) `
Date SECOND Returns the seconds component of a given date and time.
Learn more.
` SECOND(datetime_expression) `
Date TODATE Returns a formatted compatibility mode Date. Learn more. ` TODATE(X, Input Format, Output Format) `
Date TODAY Returns the current date as of the specified or default timezone.
Learn more.
` TODAY([time_zone]) `
Date UNIX_DATE Returns the number of days since 1970-01-01.
Learn more.
` UNIX_DATE(date_expression) `
Date WEEK Returns the week number for a given date.
Learn more.
` WEEK(Date) `
Date WEEKDAY Returns a number representing the day of the week for a given date.
Learn more.
` WEEKDAY(Date) `
Date YEAR Returns the year of a given date.
Learn more.
` YEAR(Date) `
Date YEARWEEK Returns the year and week number of a given date.
Learn more.
` YEARWEEK(Date) `
Geo TOCITY Returns the city name for X. ` TOCITY(X [,Input Format]``) `
Geo TOCONTINENT Returns the continent name for X.
Learn more.
` TOCONTINENT(X [,Input Format]``) `
Geo TOCOUNTRY Returns the country name for X.
Learn more.
` TOCOUNTRY(X [,Input Format]``) `
Geo TOREGION Returns the region name for X.
Learn more.
` TOREGION(X [,Input Format]) `
Geo TOSUBCONTINENT Returns the sub-continent name for X.
Learn more.
` TOSUBCONTINENT(X [,Input Format]) `
MiscellaneousCASTCast field or expression into TYPE. Aggregated fields are not allowed inside CAST.`TYPE` can be `NUMBER`, `TEXT`, or `DATETIME`.
Learn more.
`CAST(field_expression AS TYPE)`
MiscellaneousHYPERLINKReturns a hyperlink to the URL, labeled with the link label.
Learn more.
`HYPERLINK(URL, link label)`
MiscellaneousIMAGECreates Image fields in your data source
Learn more.
`IMAGE(Image URL, [Alternative Text])`
Text CONCAT Returns a text that is the concatenation of X and Y.
Learn more.
` CONCAT(X, Y) `
Text CONTAINS_TEXT Returns true if X contains text, otherwise returns false. Case-sensitive.
Learn more.
` CONTAINS_TEXT(X, text) `
Text ENDS_WITH Returns true if X ends with text, otherwise returns false. Case-sensitive.
Learn more.
` ENDS_WITH(X, text) `
Text LEFT_TEXT Returns a number of characters from the beginning of X. The number of characters is specified by length.
Learn more.
` LEFT_TEXT(X, length) `
Text LENGTH Returns the number of characters in X.
Learn more.
` LENGTH(X) `
TextLOWERConverts X to lowercase.
Learn more.
`LOWER(X)`
Text REGEXP_EXTRACT Returns first matching substring in X which matches the regular expression pattern.
Learn more.
` REGEXP_EXTRACT(X, regular_expression) `
Text REGEXP_MATCH Returns true if X matches the regular expression pattern, otherwise returns false.
Learn more.
` REGEXP_MATCH(X, regular_expression) `
Text REGEXP_REPLACE Replaces all occurrences of text which matches the regular expression pattern in X with the replacement string.
Learn more.
` REGEXP_REPLACE(X, regular_expression, replacement)`
Text REPLACE Returns a copy of X with all occurrences of Y in X replaced by Z.
Learn more.
` REPLACE(X, Y, Z) `
Text RIGHT_TEXT Returns a number of characters from the end of X. The number of characters is specified by length.
Learn more.
` RIGHT_TEXT(X, length) `
Text STARTS_WITH Returns true if X starts with text. Otherwise, returns false. Case-sensitive.
Learn more.
` STARTS_WITH(X, text) `
Text SUBSTR Returns a text that is a substring of X. The substring begins at start index and is length characters long.
Learn more.
` SUBSTR(X, start index, length) `
Text TRIM Returns X with leading and trailing spaces removed.
Learn more.
` TRIM(X) `
Text UPPERConverts X to uppercase.
Learn more.
` UPPER(X)`