Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+
Row

PivotDataField.GetPivotData(PivotItemReference[]) Method

Retrieves summary data for the specified items of the pivot table.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v20.2.Core.dll

Declaration

CellValue GetPivotData(
    params PivotItemReference[] references
)

Parameters

Name Type Description
references PivotItemReference[]

An array of PivotItemReference objects specifying references to the report’s items that describe data to be retrieved.

Returns

Type Description
CellValue

A CellValue object that represents the retrieved value.

Remarks

Use the GetPivotData property to obtain summary data stored in a PivotTable report. The PivotItemReference objects allow you to specify the field and item pairs for which the data should be returned.

If the requested data cannot be retrieved, the GetPivotData method returns the #REF! error.

The following examples demonstrate how the GetPivotData property works. All examples refer to the pivot table shown in the image below.

PivotField_GetPivotData_SampleReport

Example

Result

pivotTable.DataFields[0].GetPivotData();

Returns the numeric value 148232, which is the grand total of all values in the pivot table.

// Create a reference to the "Q1" item of the "Quarter" field.
PivotItemReference item = new PivotItemReference(0, 0);
// Retrieve the summary data for this item.
pivotTable.DataFields[0].GetPivotData(item);

Returns the numeric value 67249, which is the grand total for the first quarter.

// Create a reference to the "Q1" item of the "Quarter" field.
PivotItemReference item1 = new PivotItemReference(0, 0);
// Create a reference to the "Dairy Products" item of the "Category" field.
PivotItemReference item2 = new PivotItemReference(4, 0);
// Retrieve the summary data for the specified items.
pivotTable.DataFields[0].GetPivotData(item1, item2);

Returns the numeric value 46070, which is the total of the dairy product sales for the first quarter.

// Create a reference to the "Q1" item of the "Quarter" field.
PivotItemReference item1 = new PivotItemReference(0, 0);
// Create a reference to the "Big Foods" item of the "Customer" field.
PivotItemReference item2 = new PivotItemReference(2, 1);
// Create a reference to the "Dairy Products" item of the "Category" field.
PivotItemReference item3 = new PivotItemReference(4, 0);
// Retrieve the summary data for the specified items.
CellValue value = pivotTable.DataFields[0].GetPivotData(item1, item2, item3);

Returns the numeric value 8652, which is the value of the dairy product sales for the “Big Foods” customer in the first quarter.

// Create a reference to the "Big Foods" item of the "Customer" field.
PivotItemReference item = new PivotItemReference(2, 1);
// Retrieve the summary data for this item. 
pivotTable.DataFields[0].GetPivotData(item);

Returns the #REF! error value because there is no total value of sales for the “Big Foods” customer.

// Create a reference to the "Q3" item of the "Quarter" field.
PivotItemReference item = new PivotItemReference(0, 2);
// Retrieve the summary data for this item.
pivotTable.DataFields[0].GetPivotData(item);

Returns the #REF! error value because the sales data for the third quarter is not shown in the pivot table.

See Also