You are here: Defining Files and Fields > Defining Data Manually > Static Conditional Fields

Static Conditional Fields

Fields to which a data filter is applied are conditional because they can only be accessed when the data filter is active. Conditional fields can also be made static.

Specifying a conditional field as static allows you to carry a field value forward from record to record, as long as the specified condition is false. The static parameter is useful for defining report files, because you can combine information from header records with information in detail records.

When you define conditional fields, Analyzer lets you specify whether they are static.

Note: The value of a conditional field changes when the condition no longer applies—when the condition test returns false. The value of a static conditional field does not change when the condition test returns false, only when the condition returns true.

For example, the detail lines in a report file may not contain information about the product class because the product class information is contained in a report header record type that precedes each group of detail records.

By defining the fields in the header records as static conditional fields, you can combine fields from the header records with fields from the detail records.

Defining a Static Conditional Field

First, choose the data filter for the header records and make it active. You can do this by selecting the filter name from the Fields/Filters drop-down list.

You define filtered data fields in the same way as you would fields from any data file:

1. In the data display area, click in the first data byte position and drag the mouse to the end of the field.
2. Release the mouse button. Analyzer highlights the field, identifies its data type, and the cursor begins to blink in the Name text box.
3. Enter the name of the field in the Name text box.
4. Optionally, enter the name of an alternate title in the Column Title text box (optional). Analyzer lets you give fields alternate column titles.

Note: When naming fields, do not use words that Analyzer uses for special purposes and that cannot be used as field names. For a list of words to avoid, see Reserved Keywords.

5. At this time you can specify whether this field is to be a static field by clicking on the Advanced button and checking the Static checkbox. In this example, we will not.
6. Click [Accept Entry] or press Enter. Because you are defining data that is conditional upon a data filter, Analyzer asks if the information relates to subsequent records.
7. Click [Yes] to make this field a static conditional field and to allow you to use information from this record in subsequent records. You would normally answer [Yes] if you are defining a header record type. Otherwise click [No].

Note: Clicking [Yes] is equivalent to manually checking the Static checkbox in Step 5.

8. In the same way, select the remaining fields in the header record. Notice that each field is automatically assigned the static parameter.
9. Click [Accept Entry] or press Enter. Analyzer displays the fields in the Fields list screen of the [Edit Fields/Expressions] tab.

Displaying Static Conditional Fields

Once you have defined the conditional detail fields and the static conditional header fields, you can close the Edit Table Layout tab. Analyzer automatically displays a default View for this table.

In the View, lines preceding the first header record will have blank values in all of the fields. These records represent other header records that were excluded by the data filters. Notice that data that does not meet any filter conditions is replaced with blanks for character data or with zeros for numeric data.

The first valid header record will contain information for the static conditional fields, but does not contain any field information for the detail records. The static conditional fields values are carried forward from this record for all subsequent detail records. Their value only changes when the next header record is encountered.

The first detail line encountered combines field information from the detail record with the field information from the first header record. This continues for each detail record until the next header record is encountered at which point the header field information will be updated and carried forward.

Hiding Unfiltered Records

To View only the detail records displaying the combined fields from both the header and detail records, click the filter drop-down list to select the Detail Records data filter to apply it as a global filter. Lines that do not contain detail information are now hidden.

Setting the Default Filter

You can apply this filter as the default filter to the table layout. In the [Edit Fields/Expressions] tab of the Edit Table Layout tab, double-click the filter name in the Fields list. Analyzer displays the Computed Field Definition screen.

Click on the [Advanced] button and check the Default Filter checkbox, click [OK], then press RETURN or click [Accept Entry] or press ENTER. By default, this filter will now be applied to all Views/reports and commands based on this table layout.

Processing Static Conditional Fields

In a table layout containing static conditional fields, each subsequent row’s value may relate to a previous record For this reason, you cannot rearrange the record order by sorting or indexing.

Pre-sorting, Sorting or Indexing

If you attempt to use the Sort or Index commands, Analyzer displays the message, “You may not re-order the file or use Record when the file contains static fields. Extract the required fields”. This message is also displayed when you try to join unmatched records or merge files that contain static fields.

To sort or index data from a file containing conditional or static conditional fields, you need to first create a new data file. You can do this using the Extract command to extract the detail and related header fields using the detail record data filter.

Extracting Fields

You cannot extract records from files that contain conditional or static conditional fields. You can extract only fields.

The file produced contains a new record structure with only the defined fields. It does not contain conditional or static logic and thus can be re-ordered. For more information, see Extract.