Column summation

City Project Amount Count
Carthago Arts 581.00 $ 4
Gladiators 836.00 $ 7
Neapolis Arts 766.00 $ 6
Taxes 621.00 $ 5
Taxes 842.00 $ 8
Taxes 950.00 $ 5
Olympia Arts 422.00 $ 4
Arts 599.00 $ 0
Taxes 152.00 $ 7
Roma Arts 806.00 $ 5

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 Arts 581.00 $ 4
Gladiators 836.00 $ 7
Carthago subtotal1417.00 $11
Neapolis Arts 766.00 $ 6
Taxes 621.00 $ 5
Taxes 842.00 $ 8
Taxes 950.00 $ 5
Neapolis subtotal3179.00 $24
Olympia Arts 422.00 $ 4
Arts 599.00 $ 0
Taxes 152.00 $ 7
Olympia subtotal1173.00 $11
Roma Arts 806.00 $ 5
Roma subtotal806.00 $5
Total6575.00 $51

Group by project and city, totals for amount only, customize labels.

Project City Amount Count
Arts Olympia 422.00 $ 4
Carthago 581.00 $ 4
Olympia 599.00 $ 0
Neapolis 766.00 $ 6
Roma 806.00 $ 5
partial amount3174.00 $
Gladiators Carthago 836.00 $ 7
partial amount836.00 $
Taxes Olympia 152.00 $ 7
Neapolis 621.00 $ 5
842.00 $ 8
950.00 $ 5
partial amount2565.00 $
full total6575.00 $

Totals for amount and count, without groups.

City Project Amount Count
Carthago Arts 581.00 $ 4
Carthago Gladiators 836.00 $ 7
Neapolis Arts 766.00 $ 6
Neapolis Taxes 621.00 $ 5
Neapolis Taxes 842.00 $ 8
Neapolis Taxes 950.00 $ 5
Olympia Arts 422.00 $ 4
Olympia Arts 599.00 $ 0
Olympia Taxes 152.00 $ 7
Roma Arts 806.00 $ 5
6575.00 $51

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
Arts
$581.00 4
Gladiators
$836.00 7
Carthago Subtotal $1417.00 11
Neapolis
Arts
$766.00 6
Taxes
$621.00 5
$842.00 8
$950.00 5
Taxes Subtotal $2413.00 18
Neapolis Subtotal $3179.00 24
Olympia
Arts
$422.00 4
$599.00 0
Arts Subtotal $1021.00 4
Taxes
$152.00 7
Olympia Subtotal $1173.00 11
Roma
Arts
$806.00 5
Total Across All Categories $6575.00 51