<?xml version="1.0" encoding="UTF-8"?>
<!--Arbortext, Inc., 1988-2015, v.4002-->
<!DOCTYPE pubsTask PUBLIC "-//PTC//DTD PUBS DITA Task//EN"
 "pubsTask.dtd">
<?Pub UDT template _font?>
<?Pub Inc?>
<pubsTask id="_creating_a_computed_field_63439" xml:lang="en"
xmlns:import="http://www.oberontech.com/import"
import:mapobject="Procedure_to_task_in_conceptH1"
import:style="Procedure">
<title>To create a computed field</title>
<prolog>
<metadata><keywords>
<indexterm>calculate<indexterm>computed field<indexterm>dynamic</indexterm
></indexterm></indexterm>
</keywords></metadata>
</prolog>
<pubsTaskbody>
<ol>
<li import:style="1Step"><p>From the <uicontrol import:style="GUI"
>Create Field</uicontrol> dialog box, select <codeph
import:style="Literal">Date</codeph>, <codeph import:style="Literal"
>Floating Point</codeph>, <codeph import:style="Literal">Integer</codeph
>, <codeph import:style="Literal">Logical</codeph>, or <codeph
import:style="Literal">Short Text</codeph> from the <uicontrol
import:style="GUI">Data Type</uicontrol> list. The relevant data type
settings display.</p></li>
<li import:style="1Step+"><p>Select the <uicontrol import:style="GUI"
>Computation Values</uicontrol> option.</p></li>
<li import:style="1Step+"><p>In the <uicontrol import:style="GUI"
>Computation Definition</uicontrol> field, create a computed expression
using the rules described in <xref format="dita"
href="serv_comp_comp_expression_rules.mif-1.dita" scope="local"
type="pubsConcept">Computed Expression Rules</xref>.</p><p
import:style="Bullet Text">For example:</p><ul>
<li import:style="Bullet Indent"><p>To determine how many days a Defect
item has not been worked on, create a date field called Days Inactive
and type the following expression:</p><codeblock expanse="indent"
import:style="Code Indent 2">now() - "Modified Date"</codeblock><p
import:style="Bullet Text Indent">The Days Inactive field displays
the number of days elapsed since the last edit of the Defect item.</p
></li>
<li import:style="Bullet Indent"><p>If a Project item type contains
Actual Cost and Expected Cost fields, and you want to determine if
and how much the actual cost of a project exceeds the expected cost,
create an integer or floating point field called Cost Overrun and
type the following expression:</p><codeblock expanse="indent"
import:style="Code Indent 2">"Actual Cost" - "Expected Cost"</codeblock
><p import:style="Bullet Text Indent">If the value of the Actual Cost
field exceeds the value of the Expected Cost field, the Cost Overrun
field appears after editing the item, displaying how much the actual
cost overran the expected cost.</p></li>
<li import:style="Bullet Indent"><p>To determine whether the actual
cost of a project exceeded 90 percent of what you budgeted for, type
the following expression:</p><codeblock expanse="indent"
import:style="Code Indent 2">"Actual Cost" > .90 * "Expected Cost"</codeblock
><p import:style="Bullet Text Indent">If the value of the Actual Cost
field exceeds the value of the Expected Cost field by 90 percent,
the Cost Overrun field appears after editing the item, displaying
the percentage that the actual cost overran the expected cost.</p
><p import:style="Bullet Text Indent">As project manager, you could
closely monitor project budgets by creating a query or e-mail notification
that identifies Project items where the cost has exceeded 90&nbsp;percent
of the estimated budget.</p></li>
</ul></li>
<li><p>To record the computation value at the time of versioning and
prevent further updates, disable the <uicontrol>Allow Computation
Updates on Versioned Items</uicontrol> option. By default, computation
values on versioned items continue to update based on the computed
field definition.</p><p>To identify computed fields that continue
to update based on the computed field definition, these are known
as <i>live fields</i>, indicated by the live field icon (<image
href="../images/liveField.png" scope="local"><alt></alt></image>) in versioned
items.</p><p>When working with versioned items through a computed
expression, there can be situations where <ph
conref="../common/text_variables.dita#text_variables/ProdName01"></ph> cannot
determine the value of the field. To indicate an unknown (or <i>ambiguous</i
>) computed field value in a versioned item, <ph
conref="../common/text_variables.dita#text_variables/ProdName01"></ph> displays
an ambiguous computation icon (<image href="../images/exclaim.png" scope="local">
<alt></alt></image>).</p></li>
<li import:style="1Step+"><p>To indicate how often the computed field
should be calculated and stored in the item’s history, select a frequency
from the <uicontrol import:style="GUI">Store to History Frequency</uicontrol
> list. Selecting a frequency is useful for historical charting. <codeph
import:style="Literal">never</codeph> is the default.</p><p
import:style="Bullet Text">To specify a custom frequency, select <codeph
import:style="Literal">never</codeph> from the list, and create an
event trigger that specifies the desired frequency. For more information
on configuring the frequency at which the field computes, see <xref
format="dita" href="serv_comp_scheduling_computation_times.mif-1.dita"
scope="local" type="pubsConcept">Scheduling Computation Times</xref
>.</p><p>If document versioning is enabled and the computed field
is configured to store to history, note the following when viewing
the item history in a versioned item:</p><ul>
<li><p>If a computed value has always been valid, the item history
records the valid value.</p></li>
<li><p>If a computed value has always been ambiguous, the item history
records the ambiguous computation icon (<image href="../images/exclaim.png"
scope="local"><alt></alt></image>).</p></li>
<li><p>If a computed value was previously valid and is currently ambiguous,
the item history records the valid value.</p></li>
</ul></li>
<li import:style="1Step+"><p>From the <uicontrol import:style="GUI"
>How to Run Computations</uicontrol> list, select one of the following
computation types:</p><ul>
<li import:style="Bullet Indent"><p><codeph import:style="Literal"
>static</codeph> calculates the field based on a schedule and stores
it in the item’s history based on the value selected in the <uicontrol
import:style="GUI">Store to History Frequency</uicontrol> list. Columns
for static fields are stored in the item’s row of the database. You
should select <codeph import:style="Literal">static</codeph> if your
expression involves intensive external functions, such as query or
aggregate functions. For more information on calculating a static
computed field, see <xref format="dita"
href="serv_comp_calculating_static_computed_fields.mif-1.dita"
scope="local" type="pubsConcept">Calculating Static Computed Fields</xref
>.</p></li>
<li import:style="Bullet Indent"><p><codeph import:style="Literal"
>dynamic</codeph> calculates the field every time field values are
retrieved. By default, columns for dynamic fields are not stored in
the item’s row of the database; however, you can select <codeph
import:style="Literal">dynamic</codeph> and a frequency from the <uicontrol
import:style="GUI">Store to History Frequency</uicontrol> list. <codeph
import:style="Literal">dynamic</codeph> is the default.</p><note><p
><ul>
<li import:style="NoteBodyBullet"><p>Because dynamically computed
fields are not stored in the database, dynamically computed short
text fields cannot be located with an all text field search in the <ph
conkeyref="text_variables/ProdName05"></ph>. To search for dynamically
computed short text fields, create a query that includes a specific
“field contains” comparison. If the query does not include additional
filters, the query may not return optimal results.</p></li>
<li import:style="NoteBodyBullet"><p>To avoid performance issues when
working with queries, do not use dynamic computed fields in query
definitions. As a workaround you could create a rule based event trigger
that fires when a relationship field changes, storing the count in
a regular integer field.</p></li>
<li import:style="NoteBottomBullet"><p>To avoid performance issues
when working with large documents, ensure that any computed fields
in Requirements are static, not dynamic. </p><?Pub Caret -1?></li>
</ul></p></note></li>
</ul></li>
<li import:style="1Step+"><p>Fill out the remaining fields and tabbed
panels. </p></li>
<li import:style="1Step+"><p>Click <uicontrol import:style="GUI">OK</uicontrol
> to save your changes.</p></li>
</ol>
</pubsTaskbody>
</pubsTask>
