Functions for Segments
Functions let you apply standard mathematical operators to your segment. You can also combine different functions and database fields in an expression.
After you drag a function to the expression on the Edit Expression window, you must enter the variables used in the function. You can either type the variables in the Expression field or, if the variable is an item listed in the Available Columns/Functions field, you can drag the item into the function of the expression.
Expression | Description |
---|---|
Aggregate Functions | Select from the following to use an aggregate
function in the expression. Aggregate functions are available only when defining group filters. See Create a Group Filter. |
avg(expr) |
This function computes an average value for the data set |
count(expr) |
This function returns the number of rows included in the data set |
first(expr, sort column1[, sort column2][,...]) |
This function returns the first value in the data set |
group_concat(expr, separator[, sort column 1, ASC|DESC][, sort column 2, ASC|DESC][,...]) |
This function lets you combine multiple values from data set |
last(expr, sort column1[, sort column2][,...]) |
This function returns the last value in the data set |
max(expr) |
This function returns the largest numerical value, the last string in alphabetical order, or the
latest date in the data set |
min(expr) |
This function returns the smallest numerical value, the first string in alphabetical order, or
the earliest date in the data set |
sum(expr) |
This function returns the sum of the values in the data set |
sum_distinct(expr, reference) |
This function returns the sum of distinct
values in an expression for a particular record (reference) rather
than for all records of the same type in a table. For example, if
you want to calculate the sum of all quotas for a particular sales
person, you could add a function of |
stddev(expr) |
This function returns the standard deviation of |
String Functions | Select from the following to use a string function in the expression. |
concat(str1,str2) |
This function combines input character strings
from multiple expressions into a single output string. Two or more
expressions can be appended with this function. For example, the expression |
instr(str, substr) |
This function returns the numeric position (in characters) of the initial occurrence of string
|
length(str) |
This function returns the length (in characters)
of the string. For example, the expression |
lower(str) |
This function returns string |
ltrim(str) |
This function returns the string |
lpad(str1, X, str2) |
This function returns |
rpad(str1, X, str2) |
This function returns |
rtrim(str) |
This function returns the string |
substr(str, start_pos, [length]) |
This function returns a portion of the string |
to_char(expr) |
This function converts the numeric |
to_number(str) |
This function converts the character string |
upper(str) |
This function returns string |
Date Functions | Select from the following to use a date function in the expression. |
date_add(date, units, interval, round) |
This function returns the value of |
to_date(str, format) |
This function converts the string Unlike date_format, the to_date function supports only the following date formats. DD MM YYYY HH24:MI:SS DD MM YYYY HH:MI:SS AM DD MON YY DD MON YYYY DD-MM-YY DD-MM-YYYY DD.MM.YY DD.MM.YYYY DD/MM/YY DD/MM/YYYY DD/MM/YYYY HH:MI:SS AM MM-DD-YY MM-DD-YYYY MM/DD/YY MM/DD/YYYY MON DD YY MON DD YYYY MON DD YYYY HH:MI AM MON DD YYYY HH:MI:SS AM YY.MM.DD YY/MM/DD YYMMDD YYYY-MM-DD YYYY-MM-DD HH24:MI:SS YYYY-MM-DDTHHH24:MI:SS YYYY.MM.DD YYYY/MM/DD YYYYMMDD |
date_format(date, format) |
This function converts |
date_diff(date, date) |
This function returns the number of seconds
occurring between two dates. For example, the expression Another example is date_diff(sysdate(),incidents.updated). This expression returns the number of seconds between the current time and the time that incidents were last updated. Note: To change
the format of the output, use the time_format function. For example, time_format(date_diff('2009-11-26 22:25:00', '2009-11-25 10:30:00’),
'HH24h MIm SSs') returns the value 35h 55m 00s . |
date_trunc(date, units) |
This function truncates |
sysdate() |
This function returns the current system date in the format YYYY-MM-DD HH:MI:SS. |
time_format (seconds, format) |
This function converts |
date_group(expr, format) |
This function groups records together according to a date range that you specify, and includes rows for date ranges that have no associated records. If you do not want to return rows for date ranges with no records, you could use date_format instead. For example, if you have incidents created in January and March, but none in February, and create
a report with the expression for column A set to
If you changed the expression in Column A to This function can be used only when defining group filters. See Create a Group Filter. |
Logical Functions | Select from the following to use a logical function in the expression. |
if(expression, then result, else result) |
This function returns the then result if
expression is true, or returns the else result if expression is false.
For example, the expression You can use IS NULL and IS
NOT NULL as part of the expression. For example, you could use the
expression |
decode(expression, test_value_1, result_1[, test_value_2, result_2][, default]) |
This function compares The decode function can perform table lookups, letting you use text strings as test values rather
than requiring coded values. For example, you can use Review as a test value for the
expression |
nvl(expr1, expr2) |
If the value |
Math Functions | Select from the following to use a math function in the expression. |
bitand(X, Y) |
This function returns the bitwise AND of two integers, |
ceiling(X) |
This function returns the smallest integer value greater than or equal to |
floor(X) |
This function returns the largest integer less than or equal to |
power(X, Y) |
This function returns the value of |
rand() |
This function returns a random number between 0 and 1, containing up to nine decimal places. |
round(X, D) |
This function returns the value |
truncate(X, D) |
This function returns the value |
Currency Functions | Select the following to use a currency function in the expression. |
to_currency(expr, str) |
This function converts For example, for a staff member with a default currency of USD,
|