To get the total row, you need to group the data again to get a total, and 
then add this data back to the grouped data:

var total = google.visualization.data.group(groupedData, [{
    column: 0,
    type: 'number',
    modifier: function () {return 0;}
}], [{
    column: 1,
    type: 'number',
    aggregation: google.visualization.data.sum
}, {
    column: 2,
    type: 'number',
    aggregation: google.visualization.data.sum
}, {
    column: 3,
    type: 'number',
    aggregation: google.visualization.data.sum
}]);
groupedData.addRow(['Total', total.getValue(0, 1), total.getValue(0, 2), 
total.getValue(0, 3)]);

To get the total column, you can use a DataView:

var view = new google.visualization.DataView(groupedData);
view.setColumns([0, 1, 2, 3, {
    type: 'number',
    label: 'Total',
    calc: function (dt, row) {
         return dt.getValue(row, 1) + dt.getValue(row, 2) + 
dt.getValue(row, 3);
    }
}]);

Use the view to draw your Table instead of the grouped data.

On Monday, December 23, 2013 5:21:15 PM UTC-5, Sudhir Kesharwani wrote:
>
> Google Chart Gurus...
>
> I am in a situation where in I have generated a Pivot Table based on my 
> data.  I would like to add a running total on the Pivot data to get "Yearly 
> Total (as last column)" and "Region Wise Total (as last row)"
>
> The first table in the image represents the raw table and second table 
> represents pivot table (thanks to asg http://jsfiddle.net/asgallant/HkjDe/
> ) 
>
>
> <https://lh6.googleusercontent.com/-pTIS20CXQ_Q/Uri2rDHFDCI/AAAAAAAALV8/daHt8Rk_Kls/s1600/temp.png>
> Any idea how could i add a running total within pivot data?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to