Using calculated values in reports
You can use several methods to include calculated values in a QMF report. These methods are: including calculations in the query with SQL statements, defining a new column based on an expression, and specifying and using expressions defined on the FORM.CALC panel.
The first method of including calculations in a report is handled by the database, and the other two are handled by QMF from specifications made on the form. When calculations are specified on the form, they are evaluated using REXX.
QMF verifies conditions, column definitions, and expressions whenever a form is loaded, imported, displayed, or run with a query. When you modify a condition, column definition, or expression, QMF verifies it again. A REXX error can result if QMF passes unexpected data during verification. To avoid this kind of REXX error, include your calculation, along with validation statements, in a REXX program.
When using FORM.CONDITIONS or FORM.COLUMNS (Column Definition), make sure the expression or program returns the same value if invoked multiple times with the same parameters. If the program does not return the same value, breaks might not resolve as expected, and summary values might not match printed results.
There can be a significant difference in performance, capability, and flexibility of calculations performed by the database and those evaluated using REXX. A REXX program can return values dependent upon complex logic or the values processed by REXX functions. However, although REXX offers more function and programming options, there can be some drawbacks to relying on REXX for all of the calculations in a report.
((Column A - Column B) * 100) / Column B
To create the column, you can enter the expression in SQL and rerun the query, or enter the expression as the definition for a new column in the form and display the report. Because the column defined in the form requires a call to REXX for every detail row processed for the report, you might decide to define the new column in the query.