Skip to main content
A newer version of this page is available. .

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.

CalculatedFields_UnderlyingLevelCalculation

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.

UnderlyingCalcField_Underlying_and_AggregatedData

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.

SummaryCalcField_UnderlyingData

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.

SummaryCalcField_UnderlyingData

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.

The aggr function aggregates and summarizes underlying data using the detail level specified by a predefined set of dimensions and a specified summary function. This function can be used during the creation of a new calculated field in the Expression Editor.

The aggr function has the following syntax.

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

The first argument is a summary expression calculated against a specific data source field. The next arguments are the set of dimensions whose values are aggregated and used to calculate summaries specified using the first argument.

For instance, the following function calculates sums of sales for each product within the specified category.

aggr(Sum([Sales]), [Category], [Product])

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.