Column summation
| City | Project | Amount | Count |
|---|---|---|---|
| Carthago | Army | 679.00 $ | 1 |
| Neapolis | Army | 704.00 $ | 1 |
| Arts | 303.00 $ | 9 | |
| Arts | 985.00 $ | 1 | |
| Gladiators | 71.00 $ | 1 | |
| Olympia | Gladiators | 284.00 $ | 6 |
| Taxes | 779.00 $ | 3 | |
| Taxes | 987.00 $ | 0 | |
| Roma | Arts | 0.00 $ | 6 |
| Arts | 729.00 $ | 9 |
The table above shows a simple report, grouped by the "city" value, and with some amount.
The following tables are based on the same code, with the only addition of a table decorator
org.displaytag.decorator.TotalTableDecorator
.
The decorator will generate totals for any column with the
total
attribute set, and subtotal rows by grouping using the column with a
group
attribute set to 1.
Group by city, total for amount and count
| City | Project | Amount | Count |
|---|---|---|---|
| Carthago | Army | 679.00 $ | 1 |
| Carthago subtotal | 679.00 $ | 1 | |
| Neapolis | Army | 704.00 $ | 1 |
| Arts | 303.00 $ | 9 | |
| Arts | 985.00 $ | 1 | |
| Gladiators | 71.00 $ | 1 | |
| Neapolis subtotal | 2063.00 $ | 12 | |
| Olympia | Gladiators | 284.00 $ | 6 |
| Taxes | 779.00 $ | 3 | |
| Taxes | 987.00 $ | 0 | |
| Olympia subtotal | 2050.00 $ | 9 | |
| Roma | Arts | 0.00 $ | 6 |
| Arts | 729.00 $ | 9 | |
| Roma subtotal | 729.00 $ | 15 | |
| Total | 5521.00 $ | 37 |
Group by project and city, totals for amount only, customize labels.
| Project | City | Amount | Count |
|---|---|---|---|
| Army | Carthago | 679.00 $ | 1 |
| Neapolis | 704.00 $ | 1 | |
| partial amount | 1383.00 $ | ||
| Arts | Roma | 0.00 $ | 6 |
| Neapolis | 303.00 $ | 9 | |
| Roma | 729.00 $ | 9 | |
| Neapolis | 985.00 $ | 1 | |
| partial amount | 2017.00 $ | ||
| Gladiators | Neapolis | 71.00 $ | 1 |
| Olympia | 284.00 $ | 6 | |
| partial amount | 355.00 $ | ||
| Taxes | Olympia | 779.00 $ | 3 |
| 987.00 $ | 0 | ||
| partial amount | 1766.00 $ | ||
| full total | 5521.00 $ |
Totals for amount and count, without groups.
| City | Project | Amount | Count |
|---|---|---|---|
| Carthago | Army | 679.00 $ | 1 |
| Neapolis | Army | 704.00 $ | 1 |
| Neapolis | Arts | 303.00 $ | 9 |
| Neapolis | Arts | 985.00 $ | 1 |
| Neapolis | Gladiators | 71.00 $ | 1 |
| Olympia | Gladiators | 284.00 $ | 6 |
| Olympia | Taxes | 779.00 $ | 3 |
| Olympia | Taxes | 987.00 $ | 0 |
| Roma | Arts | 0.00 $ | 6 |
| Roma | Arts | 729.00 $ | 9 |
| 5521.00 $ | 37 |
If you need subtotals for subgroups, try the MultilevelTotalTableDecorator. Items with only one entry are not totaled separately, but items that occur more than once are subtotaled together.
| City | Project | Amount | Count |
|---|---|---|---|
| Carthago | |||
| Army | |||
| $679.00 | 1 | ||
| Neapolis | |||
| Army | |||
| $704.00 | 1 | ||
| Arts | |||
| $303.00 | 9 | ||
| $985.00 | 1 | ||
| Arts Subtotal | $1288.00 | 10 | |
| Gladiators | |||
| $71.00 | 1 | ||
| Neapolis Subtotal | $2063.00 | 12 | |
| Olympia | |||
| Gladiators | |||
| $284.00 | 6 | ||
| Taxes | |||
| $779.00 | 3 | ||
| $987.00 | 0 | ||
| Taxes Subtotal | $1766.00 | 3 | |
| Olympia Subtotal | $2050.00 | 9 | |
| Roma | |||
| Arts | |||
| $0.00 | 6 | ||
| $729.00 | 9 | ||
| Arts Subtotal | $729.00 | 15 | |
| Roma Subtotal | $729.00 | 15 | |
| Total Across All Categories | $5521.00 | 37 |