Intro
You can use this reference guide to learn about supported functions in Beast Mode.
Video - Intro to Beast Mode
Supported functions
You can use any of the following functions in calculations. You can see examples of many of the functions in Sample Beast Mode calculations.
Aggregate functions
Function Name |
Description |
Example |
---|---|---|
|
Returns the approximate count of a number of unique values in a column. |
|
|
Returns the average value for each series in a column. |
|
|
Returns the highest value for each series in a column. This function differs from the MAX function in that CEILING is rounded whereas MAX is not rounded. |
|
|
Returns the number of row values in a column. |
|
|
Returns the count of a number of unique values in a column. |
|
|
Returns the lowest value for each series in a numeric column. This function differs from the MIN function in that FLOOR is rounded whereas MIN is not. |
|
|
Returns the highest value for each series in a numeric column. This function differs from the CEILING function in that MAX is not rounded whereas CEILING is rounded. |
|
|
Returns the lowest value for each series in a numeric column. This function differs from the FLOOR function in that MIN is not rounded whereas FLOOR is rounded. |
|
|
Returns the population standard deviation for each series in a numeric column. |
|
|
Returns the sum of each series in a numeric column. |
|
|
Returns the sum of unique values in a numeric column. |
|
|
Returns the population standard variance for each series in a numeric column. |
|
For information about using aggregate functions in summary numbers, see Applying a calculation to a summary number.
Mathematical functions
Function Name |
Description |
Example |
---|---|---|
|
Returns the absolute value for all values in a numeric column. In other words, any negative values become positive, and positive values stay the same. This is valuable when you want to see aggregation without considering positive and negative values. |
|
|
Returns the remainder of each value in a numeric column divided by some specified number (dividend). |
|
|
Returns each value in a numeric column raised to a given power. If the column contains multiple series, the values are summed for each series. |
|
|
Returns random values between 0 and 1. |
|
|
Returns values in a numeric column rounded to the nearest specified decimal place. If you do not include a decimal place value in the function, returned values are rounded to the nearest whole number. |
|
Logical functions
Function Name |
Description |
Example |
---|---|---|
|
Use to begin logical statements in which the value of data is replaced when certain criteria is reached (when...then or when...then, else). These statements use the following format: or
In other words, when the data in the "Value" column equals number x, value resultx is returned; otherwise value resulty is returned. (The value returned can be either a single-quoted string or a number.) For multiple conditional statements, use the following format: Although valid, avoid using the following inefficient format: IN Operator LIKE Operator
Values for the LIKE operator are matched in order of the WHEN statements. For example, if a value in the data matches the first and fourth LIKE operators, it is applied to the first operation. |
|
|
Used in logical statements in which you want to specify a replacement for null values. |
|
|
Returns null if the value in the first column equals the value in the second column; otherwise returns the value in the first column. |
|
Video - Case Statement Overview
String functions
Function |
Description |
Example |
---|---|---|
|
Combines strings from two or more string columns. |
|
|
Returns the position of the first instance of a specified string in a given column, starting from the first letter in the name. In the example at right, the calculation would return the position of the first instance of the letter "e" in each string in the column. |
|
|
Returns the specified number of characters in each string in the the given column, starting from the left. |
|
|
Returns the number of characters in each string in the given column. |
|
|
Converts strings from one or more string columns into lower-case. |
|
|
Replaces all of the specified strings in a given column with another specified string. |
|
|
Returns the specified number of characters in the given column, starting from the right. |
|
|
Extracts and returns a specified number of characters from the values in a string column. You specify the characters to return by indicating the starting position and the length of characters. For example, specifying the position as 1 and the length as 3 would return the first, second, and third characters for values in the column. |
|
|
Trims leading and trailing spaces for all values in string columns. |
|
|
Converts strings from one or more string columns into upper-case. |
|
Date and Time functions
Function |
Description |
Example |
---|---|---|
|
Adds date or datetime values (as intervals) to date values in a date column. You can specify the date or datetime values to add to date values in a date column by specifying the column, interval, expression, and unit, as in ADDDATE(`datecolumn`, interval expr unit) where datecolumn is the column containing a date value, where expr is the argument containing the date or datetime value to add, and where unit is the string value for the corresponding date or datetime unit type. You can prefix the expression with a "-" to subtract the value. Specify the unit value (such as second, minute, hour, day, week, month, quarter, year). (The "interval" keyword and unit type values are case insensitive.) For more information, see Unit type values in Beast Mode. For example, adding 12 days to January 4 would return January 16. Same as DATE_ADD. |
|
|
Adds a specified number of seconds to all values in a time column. For example, adding 15 seconds to 8:05 would return 8:20. |
|
|
Returns the current date. No column name is specified in this function. Same as CURRENT_DATE. |
|
|
Returns the current time. No column name is specified in this function. Same as CURRENT_TIME. |
|
|
Returns the current date. No column name is specified in this function. Same as CURDATE. |
|
|
Returns the current time. No column name is specified in this function. Same as CURTIME. |
|
|
Returns the value of current date and time in YYYY-MM-DD HH:MM:SS format. No column name is specified in this function. Same as NOW. |
|
|
Extracts and returns the dates from datetime values. |
|
|
Returns the number of days between two dates from datetime values. |
|
|
Adds date or datetime values (as intervals) to date values in a date column. You can specify the date or datetime values to add to date values in a date column by specifying the column, interval, expression, and unit, as in DATE_ADD(`datecolumn`, interval expr unit) where datecolumn is the column containing a date value, where expr is the argument containing the date or datetime value to add, and where unit is the string value for the corresponding date or datetime unit type. You can prefix the expression with a "-" to subtract the value. Specify the unit value (such as second, minute, hour, day, week, month, quarter, year). (The "interval" keyword and unit type values are case insensitive.) For more information, see Unit type values in Beast Mode. For example, adding 12 days to January 4 would return January 16. Same as ADDDATE. |
|
|
Formats dates in a date/time column into a specific format. Note: Beast Mode uses SQL-like date and time formats.
You can specify the format to use for a date or time column by specifying the column and the date or time string, as in DATE_FORMAT(`datecolumn`,'format') where datecolumn is the column containing a date value and where format is the string containing specifier characters to use in formatting the date value. The "%" character is required before format specifier characters. For example, using DATE_FORMAT(`MyDate`,'%Y-%m-%d %h:%i %p'), the date in the MyDate date column uses this format: 2013-04-17 10:10 AM. For information about specifier characters, see Date Format Specifier Characters in Beast Mode. Similar to TIME_FORMAT. |
|
|
Subtracts date or datetime values (as intervals) to date values in a date column. You can specify the date or datetime values to subtract from date values in a date column by specifying the column, interval, expression, and unit, as in DATE_SUB(`datecolumn`, interval expr unit) where datecolumn is the column containing a date value, where expr is the argument containing the date or datetime value to subtract, and where unit is the string value for the corresponding date or datetime unit type. You can prefix the expression with a "-" to add the value. Specify the unit value (such as second, minute, hour, day, week, month, quarter, year). (The "interval" keyword and unit type values are case insensitive.) For more information, see Unit type values in Beast Mode. For example, subtracting 12 days from January 24 would return January 12. Same as SUBDATE. |
|
|
Returns the numerical day of the month for all values in a date/time column. Same as DAYOFMONTH. |
|
|
Returns the name of the day of the week for all values in a date/time column. |
|
|
Returns the numerical day of the month for all values in a date/time column. Same as DAY. |
|
|
Returns the numerical day of the week for all values in a date/time column (e.g. "2" for "Monday"). |
|
|
Returns the numerical day of the year for all values in a date/time column (e.g. "226" for the 226th day of the year). |
|
|
Converts day numbers into dates. |
|
FROM_UNIXTIME |
Returns a UNIX datetime value from a UNIX date/time column using the specified format. For information about specifier characters, see Date Format Specifier Characters in Beast Mode. |
|
|
Returns the hour for all values in a date/time column (e.g. the time "3:36" would return "3"). |
|
|
Aggregates values for each month in a date/time column and returns each aggregation as the last day of each month. For example, if a date/time column had "15," "16," and "17" as values for January, only the last given date of January would appear, with a combined value of 48. |
|
|
Returns the value for each minute in a time column. If there is more than one instance of a particular minute in the column, the values for those minutes are aggregated. |
|
|
Returns the month number (e.g. "9" for September) for all values in a date/time column. |
|
|
Returns the name of the month (e.g. "September" rather than "9") for all values in a date/time column. |
|
|
Returns the value of current date and time in YYYY-MM-DD HH:MM:SS format. No column name is specified in this function. Same as CURRENT_TIMESTAMP. |
|
|
Adds the specified number of months to the values in a date column. For this to work, the date values must be months in the format YYYYMM. |
|
|
Returns the number of months between months in two date columns. For this to work, the date values must be months in the format YYYYMM. For example, if one column contained the date value 200803 and another contained the value 200809, this function would return 6. |
|
|
Aggregates date value data into quarters in a year. |
|
|
Returns the value for each second in a time column. If there is more than one instance of a particular second in the column, the values for those seconds are aggregated. |
|
|
Converts seconds into hours, minutes, and seconds. For example, 3489 would be converted into 00:58:09. Note: The sec_to_time function is limited to 24 hours. When a value is greater than 24 hours, it will overflow and loop back to 0 hours.
|
|
|
Converts strings (that Domo does not recognize as dates) from one or more string columns into datetime values. You specify the column(s) and the current date format used in those columns. By default, datetime values are returned in the output format %m-%d-%Y. You can change the output format by enclosing your STR_TO_DATE calculation in a DATE_FORMAT calculation that specifies the date format specifier characters you want. For information about specifier characters, see Date Format Specifier Characters in Beast Mode. |
|
|
Subtracts date or datetime values (as intervals) to date values in a date column. You can specify the date or datetime values to subtract from date values in a date column by specifying the column, interval, expression, and unit, as in SUBDATE(`datecolumn`, interval expr unit) where datecolumn is the column containing a date value, where expr is the argument containing the date or datetime value to subtract, and where unit is the string value for the corresponding date or datetime unit type. You can prefix the expression with a "-" to add the value. Specify the unit value (such as second, minute, hour, day, week, month, quarter, year). (The "interval" keyword and unit type values are case insensitive.) For more information, see Unit type values in Beast Mode. For example, subtracting 12 days from January 24 would return January 12. Same as DATE_SUB. |
|
|
Subtracts a specified number of seconds from all values in a time column. For example, subtracting 30 seconds from 8:05:45 would return 8:05:15. |
|
|
Returns the current date and time in YYYY-MM-DD HH:MM:SS format, as in 2014-04-03T19:25:29. No column name is specified in this function. Similar to CURRENT_DATE and CURRENT_TIME. |
|
|
Extracts the times from datetime values. |
|
|
Returns the difference between values in two date/time columns, expressed as a time value. |
|
|
Returns values in a date column as datetime values. |
|
|
Formats time in a datetime column into a specific format. Note: Beast Mode uses SQL-like date and time formats.
You can specify the format to use for time values in a time column by specifying the column and the time string, as in TIME_FORMAT(`datetimecolumn`,'format') where datetimecolumn is the column containing a time value and where format is the string containing specifier characters to use in formatting the time value. Note: The format specifiers used in DATE_FORMAT may be used with TIME_FORMAT, but specifiers other than hours, minutes, seconds and microseconds produce a NULL value or 0.
The "%" character is required before format specifier characters. For example, using TIME_FORMAT(`Date`,'%h:%i:%s'), the date in the transformed time column uses this format: 12:20:12. For information about specifier characters, see Date Format Specifier Characters for Beast Mode Similar to DATE_FORMAT. |
|
|
Returns an elapsed number of seconds for all values in a date/time column. |
|
|
Returns the number of days since year 0 for all values in a date/time column. For example, the date "01-06-2010" would be returned as "734143," since 734,143 days have transpired between that date and January 1st of year 0. |
|
UNIX_TIMESTAMP |
Returns UNIX time stamps for all values in a date/time column. | UNIX_TIMESTAMP(`DateCol`) |
WEEK |
Returns the week number for each value of the indicated date or date-time column. Syntax: WEEK(`dateCol`, mode). For a Sunday-Saturday week frame, use mode 11: WEEK(`dateCol`, 11). For a Monday-Sunday week frame, use mode 22: WEEK(`dateCol`, 22). |
WEEK(`DateCol`,22) |
|
Returns the year for all values in a date/time column. |
|
|
Returns the year and week number for each value of the indicated date or date-time column in "YYYYWW" format. For example, a date in the 5th week of the year 2020 will return "202005". Syntax: YEARWEEK(`dateCol`, mode) For a Sunday to Saturday week frame, use mode 11: YEARWEEK(`dateCol`, 11). For a Monday to Sunday week frame, use mode 22: YEARWEEK(`dateCol`, 22). |
|
Unsupported functions
The following functions are no longer supported: SQRT
, CONVERT_TZ
, MICROSECOND
, WEEKDAY
Comments
0 comments
Please sign in to leave a comment.