Difference between revisions of "Calculated Fields"
Gadiyedwab (talk | contribs) |
Gadiyedwab (talk | contribs) |
||
Line 37: | Line 37: | ||
The table below shows all the functions that are available for field calculations. | The table below shows all the functions that are available for field calculations. | ||
− | + | {| class="wikitable" | |
+ | |- | ||
+ | ! scope="col"| Function | ||
+ | ! scope="col"| Description | ||
+ | ! scope="col"| Type | ||
+ | |- | ||
+ | | ABS(value) | ||
+ | | Absolute value | ||
+ | | Numeric, based on the type of the value | ||
+ | |- | ||
+ | | DURATION(begin,end) | ||
+ | | Difference in seconds between the begin and end | ||
+ | | Duration | ||
+ | |- | ||
+ | |} | ||
{{Template:TOC|Reporting on ServiceNow Variables|Pivot}} | {{Template:TOC|Reporting on ServiceNow Variables|Pivot}} |
Revision as of 13:12, 31 August 2015
Contents
Introduction
A calculated field is calculated from other fields in the list. The calculated field itself does not exist in the data source. Its value for each row is calculated from the values of the other fields.
The calculated value does not have to be numeric. In fact you can calculate a date, a time duration, or perform some text manipulation to create the value.
Adding a Calculated Field
To see how to add a calculated field, let's see an example. We'll start with this view showing the 10 hottest days in NYC. The temperatures are shown in Celsius.
To also show the temperatures in Fahrenheit, we'll add a calculated field by clicking the calculator button (see arrow in the above picture).
Using the Calculated Field dialog, we can build a calculation that can include arithmetic as well as a selection of functions. For this example, we only need arithmetic.
The following picture shows the list view with the calculated field:
Adding a Function to the Calculation
To demonstrate the use of functions in a calculation, let's continue with our example, and calculate the number of years ago when we saw that temperature.
The calculation extract the year part of the date and subtract it from the year part of today's date. The TODAY() function returns today's date. The YEAR() function returns the year part of the date as a number.
Next is the list view with the "Years Ago" field.
Functions
The table below shows all the functions that are available for field calculations.
Function | Description | Type |
---|---|---|
ABS(value) | Absolute value | Numeric, based on the type of the value |
DURATION(begin,end) | Difference in seconds between the begin and end | Duration |