Creating Calculations
Calculations are easily created, as long as all the data you need is available in the report.
To begin creating a calculation:
Click ‘Actions’ -> ‘Format’ -> ‘Compute’.
Note: It is important to give your new calculation a name if you want to use it again later! Enter a name into the 'Column Label' field.
Once you have named your calculation, it is time to create a computation expression. This is where you can enter the expression you wish to perform on the report columns of your choice. To help you with your expression there are three handy tools:
The ‘Columns’ list displays all columns in the current report
‘Keypad’ contains mathematical operators and integers that can be used in your expression
‘Functions/Operators’ contains a list of useful mathematical operators and functions
Comparison operators
Comparison operators
Operator | Meaning | Examples |
!= (Not Equal To) | Tests if two values are not the same. |
|
< (Less Than) | Tests if the first value is smaller than the second. |
|
<= (Less Than or Equal To) | Tests if the first value is smaller or equal to the second. |
|
= (Equal To) | Tests if two values are the same. |
|
> (Greater Than) | Tests if the first value is larger than the second. |
|
>= (Greater Than or Equal To) | Tests if the first value is larger or equal to the second. |
|
Mathematical functions
Mathematical functions
Functions | Meaning | Examples |
ABS | Returns the absolute value of a number. |
|
CEIL | Rounds a number up to the nearest integer. |
|
COS | Calculates the cosine of a number (in radians) |
|
EXP | Calculates the exponential value of a number (e raised to the power of the number). |
|
FLOOR | Rounds a number down to the nearest integer. |
|
GREATEST | Returns the largest value from a list of values |
|
LEAST | Returns the smallest value from a list of values |
|
LOG | Calculates the natural logarithm of a number |
|
MOD | Returns the remainder after division of one number by another |
|
POWER | Raises a number to the power of another number. |
|
ROUND | Rounds a number to a specified number of decimal places. |
|
SIGN | Returns -1 if a number is negative, 0 if zero, and 1 if positive |
|
SIN | Calculates the sine of a number (in radians). |
|
SQRT | Calculates the square root of a number |
|
TRUNC | Truncates a number to a specified number of decimal places. |
|
Date and time functions
Date and time functions
Functions | Meaning | Example |
ADD_MONTHS | Adds a specified number of months to a date. |
|
CURRENT_DATE | Returns the current date. |
|
CURRENT_TIMESTAMP | Returns the current date and time. |
|
LAST_DAY | Returns the last day of the month for a given date |
|
MONTHS_BETWEEN | Calculates the number of months between two dates. |
|
NEXT_DAY | Returns the date of the first weekday named that is later than a given date. |
|
SYSDATE | Synonym for CURRENT_DATE. | |
SYSTIMESTAMP | Synonym for CURRENT_TIMESTAMP |
Text Functions
Text Functions
Functions | Meaning | Examples |
CHR | Returns the character corresponding to a specified ASCII code. |
|
INITCAP | Capitalizes the first letter of each word in a string |
|
INSTR | Searches for a substring within a string and returns its position. |
|
LENGTH | Returns the number of characters in a string. |
|
LOWER | Converts all characters in a string to lowercase |
|
LPAD | Pads the left side of a string with a specified character up to a given length. |
|
LTRIM | Removes leading spaces from a string. |
|
REPLACE | Replaces all occurrences of a substring within a string with another substring. |
|
RPAD | Pads the right side of a string with a specified character up to a given length. |
|
RTRIM | Removes trailing spaces from a string. |
|
SUBSTR | Extracts a portion of a string. |
|
TRANSLATE | Replaces specific characters in a string with other characters. |
|
TRIM | Removes leading and trailing spaces from a string. |
|
UPPER | Converts all characters in a string to uppercase. |
|
Other Functions and Operators
Other Functions and Operators
Operators | Meaning | Examples |
AND | Logical AND operator. |
|
BETWEEN | Tests if a value is within a specified range. |
|
CASE | Allows conditional expressions (similar to IF-THEN-ELSE logic). | SQL |
COALESCE | Returns the first non-null value from a list of values. |
|
DECODE | Compares a value to a series of search values and returns the corresponding result value. | DECODE(Region, 'North America', 'NA', 'Europe', 'EU', 'Other') |
ELSE | Used in CASE statements for alternative conditions. | |
END | Marks the end of a CASE statement. | |
IN | Tests if a value is contained within a list of values. |
|
IS | Used to check for NULL values. |
|
LIKE | Tests if a string matches a pattern (using wildcards like % and _). |
|
NOT | Logical NOT operator. |
|
NOT BETWEEN | Tests if a value is outside a specified range. |
|
NOT IN | Tests if a value is not contained within a list of values. |
|
NOT LIKE | Tests if a string does not match a pattern. |
|
NULL | Represents a missing or unknown value. | |
NVL | Synonym for COALESCE | |
OR | Logical OR operator. |
|
Regular Expression Functions
Regular Expression Functions
Functions | Meaning | Examples |
REGEXP_INSTR | Similar to INSTR, but uses regular expressions for pattern matching. |
|
REGEXP_LIKE | Similar to LIKE, but uses regular expressions for pattern matching. |
|
REGEXP_REPLACE | Similar to REPLACE, but uses regular expressions for pattern matching |
|
REGEXP_SUBSTR | Similar to SUBSTR, but uses regular expressions for pattern matching. |
|
Data Conversion Functions
Data Conversion Functions
TO_CHAR | Converts a date or number to a string |
|
TO_DATE | Converts a string to a date. |
|
TO_TIMESTAMP | Converts a string to a timestamp. |
|
Common filters expressions and their descriptions
Common filters expressions and their descriptions
Expression | Description |
trunc(CU 'mm') | truncate column CU (calculation Date) to month level |
trunc(sysdate) | Today (00:00 to 23:59 of the current day) |
trunc(sysdate, 'w') | The current calendar week |
trunc(sysdate - 7, 'w') | The previous calendar week |
trunc(sysdate, 'mm') | The current calendar month |
add_months(trunc(sysdate, 'mm'), -1) | The previous calendar month |
trunc(sysdate, 'yyyy') | The current calendar year |
add_months(trunc(sysdate - case when sysdate > add_months(trunc(sysdate,'yyyy'), 3) + 6 then 0 else 365 end, 'yyyy'),3) + 5 | The current tax year |
Info: Format Mask can be used if your expression needs to be displayed at a certain precision or if a date, in a certain format.
Note: If the format you require isn't on the list then don't panic! you can manually enter your own mask within the text box.
Once you are happy with your calculation, click the ‘Apply’ button.
Viewing Calculations
To access your calculation click ‘Actions’ then ‘Select Columns’.
The following menu will now display your calculation in the list of available columns. Calculations are denoted by ‘**’ at the beginning of the column name.
Ensure that calculation is under 'Display in Report', then click 'Apply'. Your calculation will be displayed in your report.