Functions for Reports
Functions let you apply standard mathematical functions to the data from your database, and output the modified data in report columns.
count()
function, you can
output the number of contacts associated with an organization. The
column’s expression in this example would be count(contacts.c_id)
. You can also combine different functions and database fields in
the same column’s expression.When you drag a function from the data dictionary to the design surface, the Column Definition window opens. This lets you enter the variables used in the function’s expression. You can either enter 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’s expression.
Function | Description |
---|---|
Aggregate Functions |
Select from the following to use an aggregate function in the expression. Aggregate functions can be used only when defining output. |
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 of
data set |
group_concat(expr, separator[, sort
column 1, ASC|DESC][, sort column 2, ASC|DESC][,...]) |
This function allows you to combine multiple
values from data set |
last(expr, sort column1[, sort column2][,...]) |
This function returns the last value of
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. See Reference Information for a list of the date/time format tokens you can use in date functions. Most of the date functions allow you to combine the supported format tokens in any combination you want. Date functions do not support dates earlier than January 1, 1970. |
date_add(date, units, interval, round) |
This function returns the value of |
to_date(str, format) |
This function converts the value entered
in Unlike other date functions, 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 date_diff('2014-07-26 22:25:00', '2014-07-25 10:30:00’) returns the value 129300. 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. To change the format of the output, use the time_format function. For example, time_format(date_diff('2014-07-26 22:25:00', '2014-07-25 10:30:00’), 'HH24h MIm SSs') returns the value 35h 55m 00s. |
rel_date_diff(date2, date1, rr_id) |
This function returns the number of seconds between two dates, taking holidays and the work
hours specified in response requirements into account. The value for For example,
if a site’s response requirements are configured with work hours from
9 A.M. to 5 P.M., the expression rel_date_diff('2014-07-26 22:25:00',
'2014-07-25 10:30:00’,1) returns the value This function isn't available for use in variables, filters, or exceptions. In addition, it cannot be nested in other expressions. |
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 lets you group records together according to a date range that you specify, and include 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 2014-01 10 2014-02 0 2014-03 15 If you changed Column A’s expression to When this function is used in a column, the report designer automatically groups the data in the output level, and sets the output level’s group and sort order options. At least one date filter is required to use this function. |
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
the expression is true and returns the else result if the 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(test expression, test value 1,
result 1, [, next test value, next result]* [,default]) |
This function compares |
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 generates a random number
between 0 and 1. This output can be used to produce a random sampling
of data. For example, to generate a random sample of incidents, add
a column with an expression of |
round(X, D) |
This function returns the value |
truncate(X, D) |
This function returns the value |
Currency Functions |
Select from the following to use a currency function in the expression. |
cvt_currency(expr, str) |
This function converts the currency value |
make_currency(expr, str) |
This function converts an integer or decimal
number to the specified currency |
to_currency(expr, str) |
This function converts an integer For example, for a user with a
default currency of |