We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Adding Calculation Column

How to I add a calculation column to a pivot grid.

Col1 - Col2

3 Replies

AK Adhikesevan Kothandaraman Syncfusion Team May 27, 2016 01:17 PM UTC

Hi Chris, 

To add PivotCalculations with the subtraction of two columns, you can use the Formula and CalculationType properties of the PivotComputationInfo. You can set the formula for compute the value of the particular column using the Formula property. Please refer to the following Code snippet,  

Code Snippet: 
// Adding PivotCalculations to the Control 
this.pivotGridControl1.PivotCalculations.Add(new PivotComputationInfo { FieldName = "Amount", Format = "#,##0", SummaryType = SummaryType.DoubleTotalSum }); 
 
this.pivotGridControl1.PivotCalculations.Add(new PivotComputationInfo { FieldName = "Quantity", Format = "#,##0" }); 
 
this.pivotGridControl1.PivotCalculations.Add(new PivotComputationInfo { FieldName = "Sub", Format = "#,##0", CalculationType = CalculationType.Formula, Formula = "[Amount] - [Quantity]" }); 
 
 
Sample Link: 
  

 


Regards, 
Adhi 
 



CB Chris Bishop May 27, 2016 02:04 PM UTC

Thank you so much!

That worked.


AK Adhikesevan Kothandaraman Syncfusion Team May 30, 2016 04:14 AM UTC

Hi Chris, 

Thanks for your update. 

We are glad to know that your query has been solved. Please let us know if you need any further assistance. 

Regards, 
Adhi 


Loader.
Live Chat Icon For mobile
Up arrow icon