The DevExpress Dashboard provides the capability to create calculated fields that allow you to apply complex expressions to data fields that are obtained from the data source. You can create calculated fields at three levels: underlying, summary and intermediate.
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.
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.
Finally, you can create custom aggregations at different levels and combine these aggregations with existing visualizations. This can be done using the Aggr function that aggregates and summarizes underlying data using the detail level specified by a predefined set of dimensions and a specified summary function. The Aggr function has the following syntax.
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.
If you created the calculated field that includes the Aggr function and dropped 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 increased or decreased granularity to the dashboard item. There are two main scenarios.
In the first scenario, an aggregation has a less detailed granularity than visualized data.
In this scenario, an underlying data source contains the list of orders for two categories and corresponding products.
To aggregate this data by individual categories, create a calculated field with the following expression.