The grand total calculations are done on top of the data aggregated in the Pivot table.
You can choose which aggregation function to use from the Grand Total selection.