Skip to main content

Calculated Fields

  • 3 minutes to read

The DevExpress Dashboard supports calculated fields that allow you to apply complex expressions to data fields obtained from the data source. As a result, you can use these fields in data visualizations as regular data source fields. You can create calculated fields at three levels: underlying, summary, and intermediate.

Underlying Level

In the image below, the ExtendedPrice field is calculated based on underlying values of UnitPrice and Quantity.


After you drop the created calculated field along with Product to the Grid dashboard item, the Dashboard will summarize its data using the specified summary function.


In this case, a calculation is performed before an aggregation.

Summary Level

You can also compute values of calculated fields on a visualization (or summary) level. In this case, the Dashboard computes calculated field values using displayed data.

The underlying data source below contains the Profit and ExtendedPrice fields.


If you want to calculate a margin, you need to divide the sum of Profit values into the sum of ExtendedPrice values. To do this, you can use the set of aggregate functions (Sum, Min, Max, etc.) that allow you to perform calculations on a visualization level.


In this case, a calculation is performed after an aggregation.

Intermediate Level

Finally, you can create custom aggregations at different levels and combine these aggregations with existing visualizations.

To set up an intermediate level aggregation, create a new calculated field and use the aggr function. This function has the following syntax:

aggr(summaryExpression, dimension1, dimension2, ...)

The first argument is a summary expression calculated against a specific data source field. The subsequent arguments are the dimensions that define the calculation level.

For instance, the following function calculates yearly product sales:

aggr(Sum([Sales]), [Product], GetYear([Date]))

The function with non-specified dimension arguments combines all data into one group. For instance, the following function calculates grand total sales:


If you create the calculated field that includes the aggr function and drop the created field into an existing dashboard item, the Dashboard joins the resulting aggregation with the already displayed data. This means that you can add data with the increased or decreased granularity to the dashboard item.

For more information about typical use cases of utilizing the aggr function, see Intermediate Level Aggregations.

How to Create a Calculated Field

The following topics show how to create calculated fields.