BackPrevious Page Next PageNext

Summaries

Aggregate functions

Predefining summaries in a catalog

Creating summaries in a catalog when needed

Summaries are a special kind of formulas that are built into JReport to save you time and effort. They can be used to generate aggregations for your data using aggregate functions such as Count, Average, Sum, and Standard Deviation. Summaries work based on how your data is grouped. For example, if you group your data according to country, and you have two groups (US and Canada), then when you add a summary to the country group, you will get the summary result for each group. The aggregation objects in a business view function the same as summaries.

This chapter introduces creating summaries in a catalog. In a report that uses business view as the data source, you can also create dynamic aggregations to use in the report specifically.

See also Summary Fields for how to work with summaries as component in a report.

Aggregate functions

The aggregate functions JReport supports for computing data are generally divided into two types: normal functions and running functions.

A normal function calculates all records and returns only one fixed value that is reset to 0 for each group.

A running function calculates a value on each record and does not reset to 0 for each group. It is like the total sum of money for each transaction that is recorded on your checkbook. Each time you deposit or withdraw money from the bank, the record will compute the total of your checking account balance. Running functions when applied in crosstabs only work on columns.

Predefining summaries in a catalog

You can predefine summaries in a catalog so as to use them directly in reports.

  1. Open the required catalog.
  2. In the Catalog Manager, expand the data source in which to create the summary, then:

    The New Summary dialog appears.

    New Summary dialog

  3. Select <Create> in the Summaries drop-down list.
  4. Select a function from the Aggregate Function drop-down list for your field to be summed by.
  5. Select a field for the summary to compute from the Resource box, then click Add Sum On button next to Summary On.
  6. If required, specify to which group the summary will be applied.
  7. Click the OK button.
  8. In the Enter Summary Name dialog, provide a name for the summary and click OK. The summary is now created in the catalog.

Creating summaries in a catalog when needed

Besides predefining summaries in a catalog via the Catalog Manager, JReport Designer also provides you quick access to create summaries in a catalog from the UI where a summary list is provided, for example in the Resources box of the report wizard. In this summary list, the <New Summary...> item is available on the top. By clicking the item, you can create any summaries you want with the New Summary dialog, which are then added into the current catalog.

Summaries will also be created automatically in a catalog when you add summaries for each group while creating a query based table or banded object with the report wizard. However all summaries created automatically by the report wizard are static summaries, so when you use the report wizard to create a lot of reports in your catalog it will become very messy with many duplicate summaries. Therefore it is better to create dynamic summaries in the catalog and add them to the data components in your reports after you generate the data components with the wizards.

BackPrevious Page Next PageNext