WebFOCUS Online Help > Managed Reporting End User > Creating a Report With Report Assistant > Creating Temporary Fields
In this section:
How to: |
A temporary field is a field whose value is not stored in the data source, but can be calculated from the data that is there, or assigned an absolute value. When you create a temporary field, you determine its value by writing an expression. You can combine fields, constants, and operators in an expression to produce a single value. For example, if your data contains salary and deduction amounts, you can calculate the ratio of deductions to salaries using the following expression: deduction / salary.
You can specify the expression yourself, or you can use one of the many supplied functions that perform specific calculations or manipulations. In addition, you can use expressions and functions as building blocks for more complex expressions, as well as use one temporary field to evaluate another.
There are two types of temporary fields—a virtual field and a calculated value—which differ in how they are evaluated:
You can create temporary fields from the Field selection tab.
The Field Creator dialog box opens.
If you are familiar with coding Compute and Define expressions, you can type the expression in the text box. Otherwise, you can use the keypad to assist you in creating the expression. To use the keypad:
The functions list displays predefined functions grouped into categories that include Character, Data Source and Decoding, Date and Time, Format Conversion, Numeric, and System. If you hover your cursor over a function, a brief description appears.
If you select a function, replace each of the function’s arguments with the desired value or field name. Note that each function is a program that returns a value.
See the Using Functions manual for complete information on functions.
Note: When you create a defined field in Report Assistant, if you want that field value to be blank, the blank must be contained in quotation marks.
Select a field in the Sum/Print display field list and click the Delete icon (or press the Delete key).
or
Perform the following steps:
The following are examples of creating a virtual field and creating a calculated value.
The following image shows the Define Field Creator dialog box with a defined field that uses a function (ARGLEN). This field uses the EMPLOYEE sample data source.
The following image shows a computed field created using the SALES sample data source. The expression creates the computed field REVENUE based on the product of the existing fields UNIT_SOLD and RETAIL_PRICE.
The following image shows the Change Format Dialog box, which you use to assign a format to a virtual or column field. Refer to the following procedures for the step-by-step instructions.
or
Click the New computed field icon.
The Field Creator dialog box opens.
or
Click the New computed field icon.
The Field Creator dialog box opens.
If the selected field matches the selected format type, its current length appears in the Length spin box. Otherwise, the default length appears in the Length spin box. The Decimal spin box shows the number of decimal places for Floating Point, Decimal, and Packed.
or
Click the New computed field icon.
The Field Creator dialog box opens.
You can add a percent sign to the end of a numeric value (Decimal, Integer, Floating Point format types). This numeric display option includes a percent sign along with the numeric data, but does not calculate the percent.
or
Click the New computed field icon.
The Field Creator dialog box opens.
The following table consists of a Format column for each numeric format, a Data column for its actual data value, and a Display column for how it appears.
Format |
Data |
Display |
---|---|---|
I2% |
21 |
21% |
D7% |
97 |
97% |
F3.2% |
48 |
48.00% |
In the HTML Report and Graph Assistants, calculated values (COMPUTEs) that exist in the Master File appear in the fields list with all other temporary virtual fields and calculated values. The following image shows the fields list in the HTML Report Assistant with a calculated value from the Master File (PROFIT).
Calculated values from the Master File are available in all fields lists in the HTML Report and Graph Assistant except for the fields lists that appear for Define fields and Joins.
You can use a calculated value from the Master File:
Note: The By sort is automatically converted to a Total field since calculated values are calculated after data has been sorted and aggregated, but before the report is displayed. Since sorting (BY) has already been done, the phrase BY TOTAL is used to indicate that this sort is performed after any BY sorting. This applies to calculated values from the Master File and temporary calculated values.
Note: When you use calculated values for selection criteria, the Where is automatically converted to Where Total. This occurs because the Where Total is added after the data is retrieved and sorted, but before the report is finalized. This applies to selection criteria created with calculated values from the Master File and temporary calculated values.
Calculated fields from the Master File are not supported:
These dependencies apply to calculated values from the Master File and to temporary calculated values.
When you include a calculated value in selection criteria or in a page heading/footing, the field must exist in the report as either a By sort field or a Sum/Print field. If you create a selection criteria statement with a calculated value or add a calculated value to a page heading/footing and the field does not already exist in the report, then it is automatically added to the Sum/Print display field list. The Make this field invisible option is automatically selected in the Field options dialog box so that the calculated value does not appear in the output. When this occurs, a message appears stating:
"The field has been added to the list of fields in the report."
Note: You do not see this message for temporary calculated values (those that do not come from the Master File) that are added to a page heading/footing since these already appear in the Report headings fields list.
You can change the attributes of the calculated value from the Field options dialog box on the Field selection tab. If you attempt to delete the calculated value from the Sum/Print display list and the same field exists in either selection criteria or in a page heading/footing, you receive a one of the following messages:
or
You must remove the field from the page heading/footing or selection criteria before you can remove it from the Sum/Print display list.
WebFOCUS |