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