# Summaries

Summaries are a special kind of formulas that are built into Logi 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 topic 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.

Below is a list of the sections covered in this topic:

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

## Aggregate Functions

The aggregate functions Logi 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.

**Count**

Total count of all the values in a field. For example, if you have six non-null fields in a group, the value generated by Count will be 6.**Sum**

This function sums up all the numerical values in a field. For example, if a field contains 5, 10, 15, 20 and 25, the Sum function will return 75.**Minimum**

This function finds the smallest numerical value in a field. For example, if a field contains 5, 10, 15, 20, and 25, the Minimum function will return 5.**Maximum**

This function finds the largest numerical value in a field. For example, if a field contains 5, 10, 15, 20, and 25, the Maximum function will return 25.**Average**

This function takes the average of all the numerical values in a field. For example, if a field contains 5, 10, 15, 20, and 25, the Average function will return 15.**Distinct Count**

This function takes a total count of all the distinct values in a field. If a field has 43 values and one of them is repeating 3 times, the result generated by Distinct Count will be 41.**Distinct Sum**

This function calculates the sum of a field A based on all the unique values of a field B. If the field B has 43 values and Value1 is repeating 3 times, the unique values in the field B will be 41 and Value1 is calculated once.**Population Standard Deviation**

This function uses the following equation to compute its value. PSD takes the square root of the Population Variance.**Standard Deviation**

This function uses the following equation to compute its value. SD takes the square root of the Variance.**Population Variance**

This function uses the following equation. PV sums up the square of the difference between a value and its average, and then divides the result by the total number of values.**Variance**

This function uses the following equation. Variance sums up the square of the difference between a value and its average, and then divides the result by the total number of values subtracted by one.**Running Count**

This function takes a total count on all of the records of the values in a field. It does not reset on each group break.**Running Distinct Count**

This function takes a distinct count on all of the records of the values in a field. It does not reset on each group break.**Running Sum**

This function sums up all the numerical values on all of the records in a field. It does not reset on each group break.**Running Minimum**

This function finds the smallest numerical value on all of the records in a field. It does not take the smallest numerical value of all the records in the query. The value you see is the smallest numerical value for the current and previous groups but not groups it hasn't read yet.**Running Maximum**

This function finds the largest numerical value in a field on running records. It does not take the largest numerical value of all the records in the query. The value you see is the largest numerical value for the current and previous groups but not groups it hasn't read yet.**Running Average**

This function takes the average of all the numerical values on all of the records in a field. It does not reset on each group break.

## Predefining Summaries in a Catalog

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

- Open the required catalog.
- In the Catalog Manager, expand the data source in which to create the summary, then:
- Select the
**Summaries**node or any existing summary in the data source and select**New Summary**on the Catalog Manager toolbar. - Right-click the
**Summaries**node in the data source and select**New Summary**on the shortcut menu.

The New Summary dialog appears.

- Select the
- Select
**<Create>**in the Summaries drop-down list. - Select a function from the Aggregate Function drop-down list for your field to be summed by. When DistinctSum is selected, you should select next to the Distinct On text box to specify one or more fields according to whose unique values to calculate DistinctSum using the Select Fields dialog.
- Select a field for the summary to compute from the Resource box, then select next to Summary On.
- If required, specify to which group the summary will be applied.
- If Static Summary is checked, select the field from the Resource box and select next to Group By. If the field you select is of Numeric/String/Date/Time type, you can further specify to which level data will be grouped by selecting a special function from the Special Function drop-down list. If Customize is selected, you can set the function by yourself in the Customized Function dialog.
- If Dynamic Summary is checked, first select
**Up**or**Down**from the Group By drop-down list, then in the combo box, select a value or input an integer, which should be between 0 to 127, to specify the group on which the summary will take effect.Normally you want to display the value of the group where you use the summary so leave the value 0. For example, if you select Up or Down and input 0 in the combo box and insert this summary into any group, the summary will take effect on this group; if you select Up and input 1 and insert this summary to a group, the summary will take effect on the group higher than the group where the summary is inserted, and if you specify Down and 1, it will take effect on the lower group.

The advantage of dynamic summaries is you can create one summary and use it on every group level. Using the example above with 3 groups and a final total, you still only need one dynamic summary instead of 4 static summaries since the dynamic summary can be used for each group and for the final total. Using dynamic summaries will enable you to keep a much cleaner catalog without hundreds of static summaries that can only be used in one report at one level.

A static summary defined with a group-by field can only be used in a group with exactly the same group-by field. It will be invalid anywhere else. If no group-by field is added for a static summary, the summary can be used to calculate data based on the whole dataset a data component uses. For example, if your data component is grouped by 3 groups, you would need 4 static summaries, one for each group plus one for the final total.

- Select the
**OK**button. - In the Enter Summary Name dialog, provide a name for the summary and select
**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, Logi 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 selecting 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.