Skip to main content
Row

PivotDataField.ShowValuesWithCalculation(PivotShowValuesAsType, PivotField) Method

Applies the “Show values as” calculation option to the data field to change the way summary values are displayed within the report.

Namespace: DevExpress.Spreadsheet

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

NuGet Package: DevExpress.Spreadsheet.Core

Declaration

void ShowValuesWithCalculation(
    PivotShowValuesAsType calculationType,
    PivotField baseField
)

Parameters

Name Type Description
calculationType PivotShowValuesAsType

A PivotShowValuesAsType enumeration member specifying how summary values should be displayed within the data field.

baseField PivotField

A PivotField object that specifies a base field for a custom calculation.

Remarks

When working with pivot tables, it is often more important to understand how a summary value correlates with other values in the data area than to know the summary value itself. The current ShowValuesWithCalculation method overload allows you to apply calculation options that require the PivotTable field on which to base the calculation. Only a field from the row or column area can be used as a base field, otherwise, all results will be shown as a #N/A error.

In particular, using this method, you can apply the following types of custom calculations.

  • % of Parent Total (PivotShowValuesAsType.PercentOfParent)

    Displays values in a data field as the percentage of the value of the parent item in the specified base field.

    The image below shows the pivot table with two data fields. The first one displays sales data summarized by the “Sum” function by default, while the second one shows each product’s sales as a percentage of its category total (the base field is the “Category” field).

    PivotField_ValueFieldSettings_ShowValuesAs_PercentOfParentTotal

  • Rank Smallest to Largest (PivotShowValuesAsType.RankAscending)

    Displays the rank of values for a specific base field, listing the smallest item in the field as 1, and each larger value with a higher rank value.

    The following image shows the pivot table that contains two data fields. The first one has sales data summarized by the “Sum” function, while the second one ranks sales values by the “Customer” field in ascending order (so the smallest value ranks 1st).

    PivotField_ValueFieldSettings_ShowValuesAs_RankSmallestToLargest

  • Rank Largest to Smallest (PivotShowValuesAsType.RankDescending)

    Displays the rank of values for a specific base field, listing the largest item in the field as 1, and each smaller value with a higher rank value.

    The following image shows the pivot table that contains two data fields. The first one has sales data summarized by the “Sum” function, while the second one ranks sales values by the “Customer” field in descending order (so the largest value ranks 1st).

    PivotField_ValueFieldSettings_ShowValuesAs_RankLargestToSmallest

  • Running Total In (PivotShowValuesAsType.RunningTotal)

    Displays values for successive items in the base field as a running total. This option accumulates values in the report as they run through the items of the specified base field.

    In the pivot table shown below, there are three data fields. The first one contains sales data summarized by the “Sum” function with no additional calculation applied; the second data field shows a running total of sales data for each product category over the four quarters (the base field is the “Quarter” field), and the last one displays the running total amount for the “Quarter” field in percentage terms.

    PivotField_ValueFieldSettings_ShowValuesAs_RunningTotal

  • % Running Total In (PivotShowValuesAsType.PercentOfRunningTotal)

    Calculates a running total for successive items in the base field as a percentage of the grand total value.

    In the pivot table shown below, there are three data fields. The first one contains sales data summarized by the “Sum” function with no additional calculation applied; the second data field shows a running total of sales data for each product category over the four quarters (the base field is the “Quarter” field), and the last one displays the running total amount for the “Quarter” field in percentage terms.

    PivotField_ValueFieldSettings_ShowValuesAs_RunningTotal

The following code snippets (auto-collected from DevExpress Examples) contain references to the ShowValuesWithCalculation(PivotShowValuesAsType, PivotField) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also