Grand Total, so many time, i work with same code, so thought post here in blog
Link of BIP
XML
-------------------------------------
[ROWSET]
[ROW]
[DRIVER_KEY]441[/DRIVER_KEY]
[INDUSTRY]Motor vehicle & parts dealers[/INDUSTRY]
[YEAR]2005[/YEAR]
[MONTH]March[/MONTH]
[COST]75770[/COST]
[AMOUNT]1000[/AMOUNT]
[/ROW]
[ROW]
[DRIVER_KEY]441[/DRIVER_KEY]
[INDUSTRY]Furniture & home furnishings stores[/INDUSTRY]
[YEAR]2005[/YEAR]
[MONTH]March[/MONTH]
[COST]8804[/COST]
[AMOUNT]1000[/AMOUNT]
[/ROW]
[ROW]
[DRIVER_KEY]443[/DRIVER_KEY]
[INDUSTRY]Electronics & appliance stores[/INDUSTRY]
[YEAR]2005[/YEAR]
[MONTH]March[/MONTH]
[COST]8292[/COST]
[AMOUNT]1000[/AMOUNT]
[/ROW]
[ROW]
[DRIVER_KEY]443[/DRIVER_KEY]
[INDUSTRY]Electronics & appliance stores[/INDUSTRY]
[YEAR]2006[/YEAR]
[MONTH]March[/MONTH]
[COST]6000[/COST]
[AMOUNT]1000[/AMOUNT]
[/ROW]
[ROW]
[DRIVER_KEY]441[/DRIVER_KEY]
[INDUSTRY]Electronics & appliance stores[/INDUSTRY]
[YEAR]2006[/YEAR]
[MONTH]March[/MONTH]
[COST]4000[/COST]
[AMOUNT]1000[/AMOUNT]
[/ROW]
[/ROWSET]
-------------------------------------
[?for-each-group:ROW; DRIVER_KEY?]
For each group Sub-total
COST == [? sum(current-group()/COST)?]
AMOUNT == [? sum(current-group()/AMOUNT)?]
[? sum(current-group()/COST) + sum(current-group()/AMOUNT)?]
[?end for-each?]
Grand COST Total = [?sum(ROW/COST)?]
Grand AMOUNT Total = [?sum(ROW/AMOUNT)?]
GRAND TOTAL == [?sum(ROW/COST) + sum(ROW/AMOUNT)?]
-------------------------------
Output i got.
--
For each group Sub-total 441
COST == 88574
AMOUNT == 3000
91574
For each group Sub-total 443
COST == 14292
AMOUNT == 2000
16292
Grand COST Total = 102866
Grand AMOUNT Total = 5000
GRAND TOTAL == 107866
-------------------------------
XML
-------------------------------------
[ROWSET]
[ROW]
[DRIVER_KEY]441[/DRIVER_KEY]
[INDUSTRY]Motor vehicle & parts dealers[/INDUSTRY]
[YEAR]2005[/YEAR]
[MONTH]March[/MONTH]
[COST]75770[/COST]
[AMOUNT]1000[/AMOUNT]
[/ROW]
[ROW]
[DRIVER_KEY]441[/DRIVER_KEY]
[INDUSTRY]Furniture & home furnishings stores[/INDUSTRY]
[YEAR]2005[/YEAR]
[MONTH]March[/MONTH]
[COST]8804[/COST]
[AMOUNT]1000[/AMOUNT]
[/ROW]
[ROW]
[DRIVER_KEY]443[/DRIVER_KEY]
[INDUSTRY]Electronics & appliance stores[/INDUSTRY]
[YEAR]2005[/YEAR]
[MONTH]March[/MONTH]
[COST]8292[/COST]
[AMOUNT]1000[/AMOUNT]
[/ROW]
[ROW]
[DRIVER_KEY]443[/DRIVER_KEY]
[INDUSTRY]Electronics & appliance stores[/INDUSTRY]
[YEAR]2006[/YEAR]
[MONTH]March[/MONTH]
[COST]6000[/COST]
[AMOUNT]1000[/AMOUNT]
[/ROW]
[ROW]
[DRIVER_KEY]441[/DRIVER_KEY]
[INDUSTRY]Electronics & appliance stores[/INDUSTRY]
[YEAR]2006[/YEAR]
[MONTH]March[/MONTH]
[COST]4000[/COST]
[AMOUNT]1000[/AMOUNT]
[/ROW]
[/ROWSET]
-------------------------------------
[?for-each-group:ROW; DRIVER_KEY?]
For each group Sub-total
COST == [? sum(current-group()/COST)?]
AMOUNT == [? sum(current-group()/AMOUNT)?]
[? sum(current-group()/COST) + sum(current-group()/AMOUNT)?]
[?end for-each?]
Grand COST Total = [?sum(ROW/COST)?]
Grand AMOUNT Total = [?sum(ROW/AMOUNT)?]
GRAND TOTAL == [?sum(ROW/COST) + sum(ROW/AMOUNT)?]
-------------------------------
Output i got.
--
For each group Sub-total 441
COST == 88574
AMOUNT == 3000
91574
For each group Sub-total 443
COST == 14292
AMOUNT == 2000
16292
Grand COST Total = 102866
Grand AMOUNT Total = 5000
GRAND TOTAL == 107866
-------------------------------
Comments