Server Administration > Calculations in Fields, Charts, and Reports > Creating a Computed Field
 
Creating a Computed Field
Computed fields allow you to perform calculations between multiple fields in an item, storing the result as a value in a read-only field (the computed field). Date, floating point, integer, logical, and short text field types are the only field data types that can be configured as computed fields. However, only date, floating point, integer, short text, and long text fields can be used in the computation.
Key Considerations
If you create an expression using one or more fields that a user does not have permission to view, the user sees only the fields they have permission to view.
Computed fields are calculated in the order that they appear in the item; however, if a computed field depends on the value of another computed field, it is calculated after the computed field containing the dependent value. Depending on the number of items in your database and the number of items containing computed fields that contain dependencies, it may take a long time to calculate the value of the computed fields.
Using the im analytics --recomputehistory -g command, you can calculate a computed field within a specific time frame, storing the value in the item history. This command is useful for historical trend charting; however, it does not allow you to “correct” the history of current item data. For more information, see the “Using Computed Fields to Calculate State Metrics”.
Computed text fields only accept numeric, short text, and long text fields.
You cannot create editability rules for field value attributes backed by any computed field.
If you create a dynamic computed field, but choose to later convert it to a static computed field to improve performance, see “Calculating Static Computed Fields”.
Example: Open Task Count
Open Task Count is an integer field that displays the number of open tasks (Change Orders, Defects and Test Objectives) belonging to an item and all sub-items. For products and product portfolios, only active projects are included. For project portfolios, all projects are included. The calculation assumes that only task-like objects such as Change Order and Defect expose the Task Phase field.
Computation Definition:
IsEmpty("Open Change Order Count for Project",0) +
IsEmpty("Open Defect Count",0) +
IsEmpty("Open Test Session Count",0)
Store To History Frequency: daily
How To Run Computations: static
Example: New Defect Count - Priority Critical
New Defect Count - Priority Critical is an integer field that identifies critical priority defects.
Computation Definition:
IsEmpty(Query("administrator:New Defects - Priority Critical",Project,count()), 0)
Store To History Frequency: weekly
How To Run Computations: static
Example: Test Session Tests Count
Test Session Tests Count is an integer field that displays Test cases currently defined by the Tests field on a Test Session. This is an interim field used by the Freeze Date Tests Count field.
Computation Definition:
aggregate(Tests, byDocument(true,true),sum(isTestcase() and isMeaningful() ? 1 : 0))
Store To History Frequency: never
How To Run Computations: dynamic
Example: Validated By Pass Percentage
Validated By Pass Percentage is an integer field that determines the percentage of Validated By Trace Count which have a last results of Passed. This is used by Requirements Test Coverage and Specification Test Coverage reports to display test status per requirement and per specification.
Computation Definition:
"Validated By Trace Count" > 0 ? ( (isEmpty("Validated By Pass Count",0) + 0.001)
/ "Validated By Trace Count") : 0
Store To History Frequency: daily
How To Run Computations: static
Example: Count of Related Items Based on a Specific Type
Total Related Test Types is an integer field that counts the number of Test Type items in an item’s Forward Relationships field, ignoring all other item types. This is useful for reporting on a specific item type in a relationship field (the default report recipes included in Integrity Lifecycle Manager report on all item types in the Forward Relationships field).
Computation Definition:
IsEmpty(aggregate("Forward Relationships", sum((Type = "Test_Type") ? 1: 0)), 0)
Store To History Frequency: daily
How To Run Computations: static
To create a computed field