Performing calculations on fields in a report
The following videos demonstrate how to use a calculated field to compute the age of an incident.
Creating age bucket – Part 1: This video (4:17) demonstrates how to calculate the age of an incident. | Creating age bucket – Part 2: This video (4:22) demonstrates how to create an age bucket for incidents based on their age. |
Types of formulas
You can use any of the following formula types to create your calculation:
- Simple formula—Created with the formula builder button interface. Simple formulas range from simple addition or multiplication to CASE statements.
- Predefined formula—Based on formula rules defined by an administrator or are a system default.
- Freehand SQL—Enables you to run and save a Microsoft SQL or Oracle database function, including nested functions. (See List of database functions supported for Freehand SQL.)
To create a simple formula
- On the Data page of a report you are editing, click the + button at the bottom of the field list.
- In the Calculated Field window, complete the following steps:
- In the Calculated Field Name field, enter a name for your formula.
This name is the field name in your table and chart output. - From the Formula Type drop-down list, select Simple.
- Select the data type from the Resulting Field Type field. The available options are Numeric, Text, Boolean, and Date.
- In the Calculated Field Name field, enter a name for your formula.
Use the formula buttons and field drop-down list to add components to your calculation.
You cannot type directly into the calculation area of the window, each part of the formula needs to be added using buttons. Remedy Smart Reporting does not permit you to select combinations of variables that are incompatible; therefore, options that are grayed out become active as you add in elements. The following example shows a sample CASE WHEN formula that you can construct for calculating total number of major incidents:
SUM ( CASE WHEN KPI Name = 'HPD:INC:Major_Incidents' THEN Value END )- Click Validate to ensure your calculation is not missing any components.
- Click Save.
The calculation is available in a Calculated Fields folder at the bottom of the field list on the Data page.
To use a predefined formula
- On the Data page of a report you are editing, click the + button at the bottom of the field list.
- In the Calculated Field window, complete the following steps:
- In the Calculated Field Name field, enter a name for your formula.
This name is the field name in your table and chart output. - From the Formula Type drop-down list, select Pre-Defined.
- From the Functions list, select the formula you want to apply.
The selection is specific to the type of database from which your data is sourced.
You are provided with options to complete your calculation. - Select the Resulting Field Type: Dimension or Metric.
- For each value, click Define Value, complete the fields that appear, and click OK.
- Click Save to complete your calculation.
The calculation is available in a Calculated Fields folder at the bottom of the field list on the Data page.
- In the Calculated Field Name field, enter a name for your formula.
The following tables lists the Pre-defined formulas that you can use for your calculated fields.
Formula | Description |
---|---|
Character Index/Position, ARJDBC | This function searches for one character expression inside a second character expression, returning the starting position of the first expression if found. |
Convert CLOB to Varchar (Oracle), ARJDBC | This function converts an expression of type CLOB to an expression of type Varchar. |
Convert nText to Varchar (MSSQL), ARJDBC | This function converts an expression of type nText to an expression of type Varchar. |
Convert String to Number, ARJDBC | This function converts an expression of type String to an expression of type Number. |
Current Date, ARJDBC | This function returns the current date and time. The date is returned in the DD/MM/YYYY format. |
Date Difference - In Days, ARJDBC | This function returns the difference between two date values, in days. |
Date Difference - In Seconds, ARJDBC | This function returns the difference between two date values, in seconds. |
Date, ARJDBC | This function returns the current system date. |
DateAdd, ARJDBC | This function adds a specified number value (as a signed integer) to a specified datepart of an input date value, and then returns that modified value. |
Day, ARJDBC | This function returns the day of the month from a specified date. |
First Day of Month, ARJDBC | This function returns the day of the month. |
First Day of Quarter, ARJDBC | This function returns the day of the quarter. |
First Day of Year, ARJDBC | This function returns the day of the year. |
Hour, ARJDBC | This function returns the hour part of the specified time. |
Length, ARJDBC | This function returns the number of characters of an input string. |
List Aggregation, ARJDBC | This function transforms values from a group of rows into a list of values that are delimited by a configurable separator. |
Lower, ARJDBC | This function returns a character expression after converting uppercase character data to lowercase. |
LPAD, ARJDBC | This function left-pads a string with another string, to a specified length. |
LTRIM, ARJDBC | This function returns a character expression after removing the leading blanks from the specified string. |
Minute, ARJDBC | This function returns the minute part of the specified time. |
Month Name, ARJDBC | This function returns the name of the month from a specified date. |
Month Short Name, ARJDBC | This function returns the name of the month in short format from a specified date. |
Month, ARJDBC | This function returns an integer that represents the month of the specified date. |
Quarter, ARJDBC | This function returns the quarter of the year for a specified date. |
Replace String, ARJDBC | This function replaces all occurrences of a specified string value with another string value. |
RPAD, ARJDBC | This function right-pads a string with another string, to a specified length. |
RTRIM, ARJDBC | This function returns a character expression after removing the trailing blanks from the specified string. |
Seconds, ARJDBC | This function returns the seconds part of the specified time. |
SubString, ARJDBC | This function returns part of a character for given length from start position. |
Upper, ARJDBC | This function returns a character expression after converting lowercase character data to uppercase. |
Week Day Name, ARJDBC | This function returns the weekday name for a specified date. |
Week, ARJDBC | This function returns an integer that represents the week number for a specified date. |
Weekday Number, ARJDBC | This function returns an integer that represents the weekday number for a specified date. |
Year, ARJDBC | This function returns an integer that represents the year of the specified date. |
To use Freehand SQL
- On the Data page of a report you are editing, click the + button at the bottom of the field list.
- In the Calculated Field window, complete the following steps:
- In the Calculated Field Name field, enter a name for your formula.
This name is the field name in your table and chart output. - From the Formula Type drop-down list, select Freehand SQL.
- Select the data type from the Resulting Field Type field. The available options are Auto Detect, Numeric, Text, Boolean, and Date. The default value is Auto Detect.
In the Freehand SQL editor, enter the following syntax to run the database function:
DBFN(‘<function_name>’,`<argument1>`,`<argument2>`,…`<argument10>` )where <function_name> is the name of the database function, and <argument_number> is the input parameter required by the database function. The argument must be the AR System field name for which you are calling this function. You can provide up to 10 arguments for a function. An example of this code is:
DBFN(‘reverse’,`Description`)Click Validate.
- Click Save to complete your calculation.
The calculation is available in a Calculated Fields folder at the bottom of the field list on the Data page.
- In the Calculated Field Name field, enter a name for your formula.
Example
Consider the following example of using Freehand SQL for Min( SubmitDate ) Over (PartitionBy Assigned Group ):
Database functions supported for Freehand SQL
The following table lists some of the Microsoft SQL Server and Oracle database functions that you can execute by using Freehand SQL. The list is not exhaustive and lists only a few of the database functions that AR JDBC supports.
Database | Supported functions |
---|---|
MS SQL |
|
Oracle |
|
Freehand SQL versus advanced authoring
The following table shows the key differences between FreehandSQL and advanced authoring:
Freehand SQL | Advanced authoring |
---|---|
You can use Freehand SQL for running simple database functions only. | You can use Advanced Authoring option for running simple and complex database functions containing multiple parts. For more information, see Examples of how to execute complex database functions having multiple parts. |
In Freehand SQL, you can call a function using DBFN only. | In Advanced Authoring, you can write any SQL query that is compliant with AR JDBC. |
To edit a calculated field
- Hover over the calculation in the Field List on the Data page, and click on the drop-down menu.
- Select Edit Calculation.
To delete a calculated field
- Hover over the calculation in the Field List on the Data page, and click on the drop-down menu.
- Select Delete.