The following example demonstrates how to calculate and display multiple Custom Totals for a field.
In this example, two Custom Totals are implemented for the Category Name field. The first one displays a median calculated against summary values, while the second one displays the first and third quartiles.
To accomplish this task, we create two PivotGridCustomTotal objects and set their summary type to PivotSummaryType.Custom. We also assign the Custom Totals' names to PivotGridCustomTotalBase.Tag properties to be able to distinguish between the Custom Totals when we calculate their values. Finally, we add the created objects to the Category Name field's PivotGridField.CustomTotals collection and enable the Custom Totals to be displayed for this field by setting the PivotGridFieldBase.TotalsVisibility property to PivotTotalsVisibility.CustomTotals.
Custom Total values are actually calculated in the PivotGridControl.CustomCellValue event. First, the event handler prepares a list of summary values against which a Custom Total will be calculated. For this purpose, it creates a summary datasource and copies the summary values to an array. After that, the array is sorted and passed to an appropriate method that calculates a median or quartile value against the provided array. Finally, the resulting value is assigned to the event parameter's PivotCellValueEventArgs.Value property.
Question Comments
Added By: Daniel Lipkie at: 7/3/2012 10:04:45 AM
I tried to run the example, VS 2010, DevEx 2012.1 ... the form displays but has no data.
Added By: pepitolanda1 at: 6/25/2013 3:13:24 PMThis also happend to me.
VS 2010, DevEx 2013.1 ... the form displays but has no data.
Please change the target platform in project settings to x86. The project uses an MS Access database, so, if a 64-bit driver for the Microsoft Access Database Engine is not installed, you will get InvalidOperationException.
Added By: Cindy Oakes at: 1/28/2014 6:30:33 AMIs there a project that does not use the runner. I can not install the runner on this pc because I dont' have admin rights.
plus I extracted the data from the northwind database and created me temptables to use and I am not getting data. I really need to look at the properties of the pivot grid on the form that is designed.
Added By: Constant (DevExpress Support) at: 1/28/2014 11:06:42 PMI am afraid I cannot provide you with a solution by using only the example comments interface. I suggest you create a new question in the Support Center and describe the issue there. We will be glad to assist you.
Added By: Vipul Kandivalikar at: 7/16/2014 1:26:34 PMSo I ran the example but I noticed that it doesnt display custom totals when I remove 'Product Name' from the grouping. How do I get 2 or 3 different custom total values to be displayed when I want to compute them for a single column?
Added By: John (DevExpress Support) at: 7/16/2014 11:44:34 PM To achieve this goal, enable the PivotGrid.OptionsView.ShowCustomTotalsForSingleValues option.