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.


Top of page

x
Procedure: How to Create a Temporary Field
  1. In the Data selection tab, click either of the following:
    • New define field New define field button button located immediately below the Data selection tab.

      Note: The Define tool is not available if launching the Advanced Graph Assistant from Developer Studio.

    • New computed field New compute field button button located immediately below the Available Fields tab.

    The Field Creator dialog box opens.

  2. Enter the name for the field in the Field box. Field names for temporary fields cannot exceed 66 characters.
  3. Enter the format for the field in the Format box. Click the Format button for assistance in selecting a format.
  4. Click in the expression box, located above the key pad, to enter an expression.

    If you are familiar with coding Compute and Define expressions, you can type the expression in the text box. Otherwise, you can use the key pad to assist you in creating the expression. To use the key pad:

    1. Click the Tree or List button to open the fields list or click the Functions button to open the WebFOCUS functions list.
    2. Double-click a field or function to add it to the expression box.
    3. If you select a field, complete the expression using the key pad and additional fields, as necessary.

      If you select a function, enter the values for the function arguments.

      Note: A list of predefined functions are grouped into categories that include Character, Data Source and Decoding, Date and Time, Format Conversion, Numeric, and System. Each of the available functions is a program that returns a value. See the Using Functions manual for complete information on functions.

  5. Click OK.

    New calculated values (Compute) are added to the Y-axis dimension in the query pane.

    New virtual (Define) fields are added to the fields list in the Data selection pane, where you can select them as if they were real fields.

Note: When you create a defined field, if you want that field value to be blank, the blank must be contained in quotation marks.


Top of page

x
Procedure: How to Edit a Temporary Field
  1. Select the temporary field.
  2. Click the down arrow next to the Define button and select Edit define.

    or

    Click the down arrow next to the Compute button and select Edit compute. The Field Creator dialog box opens.

  3. Make your desired edits and click OK.

Top of page

x
Procedure: How to Delete a Temporary Field
  1. Select the temporary field.
  2. Click the down arrow next to the Define button and select Delete define.

    or

    Click the X to the right of the Compute button.


Top of page

x
Changing a Field Format

How to:

The following image shows the Field format options dialog box, which you use to assign a format to a temporary field. Refer to the following procedures for the step-by-step instructions.

Field format options dialog box



x
Procedure: How to Assign an Alphanumeric Format
  1. Select the temporary field.
  2. Click the down arrow next to the Define button and select Edit define.

    or

    Click the down arrow next to the Compute button and select Edit compute.

    The Field Creator dialog box opens.

  3. Click Format.

    The Field format options dialog box opens.

  4. Select Alphanumeric from the Field type drop-down list.
  5. To assign a different length, specify a number between 1 and 256 in the Total length box.
  6. Click OK to close the Field format options dialog box.
  7. Click OK to close the Field Creator dialog box.

    The new alphanumeric format is now effective for the selected temporary field.



x
Procedure: How to Assign a Numeric Format
  1. Select the temporary field.
  2. Click the down arrow next to the Define button and select Edit define.

    or

    Click the down arrow next to the Compute button and select Edit compute.

    The Field Creator dialog box opens.

  3. Click Format.

    The Field format options dialog box opens.

  4. Select one of the following options from the Field type drop-down list:
    • Floating Point (default length 7.2)
    • Integer (default length 5)
    • Decimal (default length 12.2)
    • Packed (default length 12.2)

    If the selected field matches the selected format type, its current length appears in the Total length box. Otherwise, the default length appears in the Total length box. The Decimal box shows the number of decimal places for Floating Point, Decimal, and Packed fields.

  5. To assign a different length, specify numbers in the Total length box for format types as follows: 1- 9 for Floating Point, 1- 11 for Integer, 1- 20 for Decimal, and 1- 33 for Packed.
  6. To assign a different number of decimal places for Floating Point, Decimal, or Packed, specify the number in the Decimal box.
  7. Click OK to close the Field format options dialog box.
  8. Click OK to close the Field Creator dialog box.

    The new numeric format is now effective for the selected temporary field.



x
Procedure: How to Assign a Date Format
  1. Select the temporary field.
  2. Click the down arrow next to the Define button and select Edit define.

    or

    Click the down arrow next to the Compute button and select Edit compute.

    The Field Creator dialog box opens.

  3. Click Format.

    The Field format options dialog box opens.

  4. Select Date from the Field type drop-down list. The default date display format is MDY.
  5. To assign a different date display format, select a date format from the Formatting options list box.
  6. Click OK to close the Field format options dialog box.
  7. Click OK to close the Field Creator dialog box. The new date format is now effective for the selected temporary field.


x
Procedure: How to Add a Percent Sign to a Numeric Field

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.

  1. Select the temporary field.
  2. Click the down arrow next to the Define button and select Edit define.

    or

    Click the down arrow next to the Compute button and select Edit compute.

    The Field Creator dialog box opens.

  3. Click Format.

    The Field format options dialog box opens.

  4. In the Display options list box, select Percent sign - %.
  5. Click OK to close the Field format options dialog box.
  6. Click OK to close the Field Creator dialog box.

    The percent sign is now added to the selected temporary field.



Example: Using the Percent Sign Edit Option

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%


WebFOCUS