This example demonstrates how to determine the value type when you calculate custom summary values.
Follow the steps below to create a custom summary:
- Create an ExpressionDataBinding object.
- Pass the following expression in its constructor as a parameter:Code
Iif(IsTotal([fieldCompanyName]), 'Grand Total', IsTotal([fieldYear]), 'Grand Total', IsTotal([fieldProductName]), 'Total', IsTotal([fieldQuarter]), 'Total', Sum([ProductAmount]))
- Assign the
ExpressionDataBinding
instance to the fieldProductAmount field's DataBinding property.
Files to Review
Documentation
More Examples
- Create a Custom Summary to Display a Distinct Value Count
- Use the Other Cell’s Values in the Current Cell Value Calculation
- Aggregate Data by the Field’s First Value
Does this example address your development requirements/objectives?
(you will be redirected to DevExpress.com to submit your response)
Example Code
C#using System.Windows.Forms;
using DevExpress.XtraPivotGrid;
namespace WinPivotCustomSummaryCellType {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
// This line of code is generated by Data Source Configuration Wizard
customerReportsTableAdapter1.Fill(nwindDataSet1.CustomerReports);
ExpressionDataBinding expression = new ExpressionDataBinding();
expression.Expression = "Iif(IsTotal([fieldCompanyName]), 'Grand Total', IsTotal([fieldYear]), 'Grand Total', IsTotal([fieldProductName]), 'Total', IsTotal([fieldQuarter]), 'Total', Sum([ProductAmount]))";
fieldProductAmount.DataBinding = expression;
}
}
}
Visual BasicImports DevExpress.XtraPivotGrid
Imports DevExpress.Data.PivotGrid
Public Class Form1
Sub New()
InitializeComponent()
' This line of code is generated by Data Source Configuration Wizard
CustomerReportsTableAdapter1.Fill(NwindDataSet1.CustomerReports)
Dim expression As New ExpressionDataBinding()
expression.Expression = "Iif(IsTotal([fieldCompanyName]), 'Grand Total', IsTotal([fieldYear]), 'Grand Total', IsTotal([fieldProductName]), 'Total', IsTotal([fieldQuarter]), 'Total', Sum([ProductAmount]))"
fieldProductAmount1.DataBinding = expression
End Sub
End Class