Formulas and Summaries are objects to be computed at run time, and allow you to manipulate field data by performing calculations on it, controlling what data is displayed, and even creating new data not directly available from a database. A summary is a special formula.
A formula is a symbolic statement of the manipulations you want to perform on certain data before it is printed on your report. If your report is to contain a @Sales field and a @Cost field, for example, you may want to create a @GrossProfit formula and designate its value as @Sales - @Cost. @GrossProfit is a simple formula that tells JReport to subtract the value of the @Cost field from the value of the @Sales field and then to print the result. Formulas can be used to calculate numeric values, compare one value to another and select alternative actions based on the comparison, join multiple text strings into a single string, and for other purposes.
Reference Note: User's Guide | Writing and Using Formulas
Formulas can work on the following objects: DB-Fields, summaries, parameters, special fields and existing formulas.
- Name: Formula name.
- Precision: A column's number of decimal digits.
- SQLType: SQL type from java.sql.Types like Array, Char, Date etc.
- Scale: Number of digits to the right of the decimal point for the formula value.
- Expression: Whole statement for the formula.