Summaries
A summary is a value the template calculates from the values of several records, such as the total of the quantities, the number of lines or a running total. You put a text control in the right band and write a summary function in it, and the designer calculates it for the preview and for printing. This page describes the functions, the calculation ranges and the options.
Two ways to write a summary
- An expression with a summary function: open the Expression Editor for the text property of the control and write, for example,
sumSum([Total]). This is the clearest way, and the editor lists the functions by category. The editor is described in The expression editor. - The Summary Editor window: select the text control and open its Summary property in the Properties panel. The Summary Editor window opens.
| Option in Summary Editor | What it does | Values |
|---|---|---|
| Summary Function | The arithmetic function the control calculates. | Sum, count, average, maximum, minimum and others. |
| Summary Running | The range in which the function is calculated. | None, group, page, report. |
| Ignore Null Values | Whether empty values are skipped in the calculation. | Ticked or not ticked. |
Summary Running works like this: the group value calculates the function for each group, the page value calculates it for the page where the control appears, and the report value calculates it for the whole report. With the value none the function is not calculated. Empty values affect functions such as count and average, so set Ignore Null Values as you need.
Summary functions
The functions calculate over a range that is the group, the page or the report. Their descriptions in the editor are below.
| Function | What it calculates |
|---|---|
sumSum(Expression) | The total of all values in the range. |
sumCount(Expression) | The number of values in the range. |
sumAvg(Expression) | The average of the values. |
sumMax(Expression) and sumMin(Expression) | The largest and the smallest value. |
sumRunningSum(Expression) | The total of the values printed before the current record plus its value: the running total. |
sumRecordNumber(Expression) | The number of the current record inside the range. It starts again with each group. |
sumPercentage(Expression) | The value of the current record as a percentage of the total of the range. |
sumCarryoverSum(Expression) | The totals carried forward to the next page and brought forward from the previous one. |
sumMedian(Expression) | The middle value of the sequence. |
sumDSum, sumDCount and sumDAvg | The same as the total, count and average, but over distinct values only. |
sumStdDev, sumVar, sumStdDevP and sumVarP | Standard deviation and variance, and the same for the whole population in the last two. |
sumWAvg(Expression, Expression) | The weighted average. |
The editor does not accept a summary function inside the argument of another summary function.
Where to put a summary
The band where you put the control sets the range:
| You want | Band for the control |
|---|---|
| A total for each group | Group Footer (see Group and sort). |
| A total for each page | Page Footer. |
| A total for the whole report | Report Footer. |
| A running total on each line | Detail, with the function sumRunningSum. |
Format the result
To show the total with the number of decimals you want, set the Format String property of the control. It is described in Formatting values.
Do not pass the result of ToPrice, ToQuantity or ToBalance to a summary function: these functions return text, not a number. Sum the field itself, and then format the control. See alameen functions.
Example: totals of the lines of an invoice
A sales invoice has three lines. The values of the Total field are 1,200.00, 850.00 and 2,200.00.
- In the Detail band, add a text control with the expression
sumRunningSum([Total]). - In the Report Footer band, add a text control with the expression
sumSum([Total])and a second one with the expressionsumCount([Number]). - For each of the three controls, set Format String to
{0:N2}.
The preview prints 1,200.00, then 2,050.00, then 4,250.00 in the running total column. At the end of the report it prints the total 4,250.00 and the number of lines 3.
Related
This page applies to alameen ERP 10, version 10.1.79.764.