To define a computed field in the Report painter Design view:
Select Insert>Control>Computed Field from the menu bar.
Click where you want to place the computed field.
If the calculation is to be based on column data that changes for each row, make sure you place the computed field in the detail band.
The Modify Expression dialog box displays, listing:
InfoMaker expression functions you can use in the computed field
The columns in the report
Operators and parentheses
Enter the expression that defines the computed field as described in “Entering the expression”.
(Optional) Click Verify to test the expression.
InfoMaker analyzes the expression.
Click OK.
You can enter any valid InfoMaker expression when defining a computed field. You can paste operators, columns, and InfoMaker expression functions into the expression from information in the Modify Expression dialog box. Use the + operator to concatenate strings.
InfoMaker expressions You are entering an InfoMaker expression, not a SQL expression processed by the DBMS, so the expression follows the rules for InfoMaker expressions. For complete information about InfoMaker expressions, see Chapter 23, “Operators and Expressions.”
You can refer to other rows in a computed field. This is particularly useful in N-Up reports when you want to refer to another row in the detail band. Use this syntax:
ColumnName[x]
where x is an integer. 0 refers to the current row (or first row in the detail band), 1 refers to the next row, –1 refers to the previous row, and so on.
Table 7-1 shows some examples of computed fields.
To display |
Enter this expression |
In this band |
---|---|---|
Current date at top of each page |
|
Header |
Current time at top of each page |
|
Header |
Current page at bottom of each page |
|
Footer |
Total page count at bottom of each page |
|
Footer |
Concatenation of Fname and Lname columns for each row |
|
Detail |
Monthly salary if Salary column contains annual salary |
|
Detail |
Four asterisks if the value of the Salary column is greater than $50,000 |
|
Detail |
Average salary of all retrieved rows |
|
Summary |
Count of retrieved rows, assuming each row contains a value for EmpID |
|
Summary |
For complete information about the functions you can use in computed fields in the Report painter, see Chapter 24, “DataWindow Expression and InfoMaker Functions”.
InfoMaker provides a quick way to create computed fields that summarize values in the detail band, display the current date, or show the current page number.
To summarize values:
Select one or more columns in the DataWindow object’s detail band.
Select one of the options at the bottom of the cascading menu: Average, Count, or Sum.
The same options are available at the bottom of the Controls drop-down toolbar on the PainterBar.
InfoMaker places a computed field in the summary band or in the group trailer band if the report is grouped. The band is resized automatically to hold the computed field. If there is already a computed field that matches the one being generated, it is skipped.
To insert a computed field for the current date or page number:
Select Insert>Control from the menu bar.
Select Today() or Page n of n from the options at the bottom of the cascading menu.
The same options are available at the bottom of the Controls drop-down toolbar on the PainterBar.
Click anywhere in the DataWindow object.
If you selected Today, InfoMaker inserts a computed field
containing this expression: Today()
.
For Page n of n, the computed field contains this expression: 'Page
' + page() + ' of ' + pageCount()
.
You can add buttons to the PainterBar in the Report painter that place computed fields using any of the aggregate functions, such as Max, Min, and Median.
To customize the PainterBar with custom buttons for placing computed fields:
Place the mouse pointer over the PainterBar and select Customize from the pop-up menu.
The Customize dialog box displays.
Click Custom in the Select palette group to display the set of custom buttons.
Drag a custom button into the Current toolbar group and release it.
The Toolbar Item Command dialog box displays.
Click the Function button.
The Function For Toolbar dialog box displays.
Select a function and click OK.
You return to the Toolbar Item Command dialog box.
Specify text and microhelp that displays for the button, and click OK.
InfoMaker places the new button in the PainterBar. You can click it to add a computed field to your report the same way you use the built-in Sum button.