# Wierd Total Behaviour for Calculated Field

1. ##### Neil N
75 posts
Member since:
Aug 2012

Posted 17 Dec 2014 Link to this post

2014Q3 controls.

Field definitions

<Fields>
<telerik:PivotGridRowField Caption="Company Name" DataField="sEntityName"
UniqueName="sEntityName">
</telerik:PivotGridRowField>
<telerik:PivotGridRowField Caption="Material" DataField="Material"
UniqueName="Material">
</telerik:PivotGridRowField>
<telerik:PivotGridColumnField Caption="Year" DataField="SubmissionYear"
UniqueName="SubmissionYear">
</telerik:PivotGridColumnField>
<telerik:PivotGridColumnField Caption="Period" DataField="Period"
UniqueName="Period">
</telerik:PivotGridColumnField>
<telerik:PivotGridAggregateField Caption="KG" DataField="KG"
GrandTotalAggregateFormatString="{0:###,###.00}" UniqueName="KG" CellStyle-CssClass="ptRJ" TotalFormatString="{0:###,###.00}" DataFormatString="{0:###,###.00}">
</telerik:PivotGridAggregateField>
<telerik:PivotGridAggregateField DataField="% of Total" CalculationDataFields="KG,TotalKG" CalculationExpression="{0}/{1}" DataFormatString="{0:p}">
</telerik:PivotGridAggregateField>
</Fields>

KG = amount of a certain material for one company
TotalKG = amount of a certain material for all companies

The % of Total column is working properly for detail rows and subtotal rows.  However for the grand total row I get 6.25%, which is 100 / 16 (the number of companies) / 100.  I am expecting to see 100% as the Grand Total of Sum of KG equals the total of all materials for all companies. Bug or something else?
##### Konstantin Dikov
2004 posts

Posted 22 Dec 2014 Link to this post

Hi Neil,

Actually, the behavior that you are describing is made that way by design and the same CalculationExpression will be applied to the total fields as well. This means that in your Grand Total you will have the total of all KG values divided by the total of all TotalKG. The same behavior could be observed in the following online demo:
Due to the way that RadPivotGrid is implemented, there is no way for chancing that behavior for the PivotGridAggregateField and CalculationExpression and it will be applied to all fields in the same manner.

Best Regards,
Konstantin Dikov
Telerik

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.