CalculatedField Class
A calculated field that allows you to apply complex expressions to data fields obtained from the data source.
Namespace: DevExpress.DashboardCommon
Assembly: DevExpress.Dashboard.v21.2.Core.dll
Declaration
Remarks
The DevExpress Dashboard allows you to create calculated fields for the following data source types:
- DashboardSqlDataSource
- DashboardExcelDataSource
- DashboardEFDataSource
- DashboardObjectDataSource
- DashboardExtractDataSource
- DashboardFederationDataSource
To manage calculated fields of the specified data source, use the CalculatedFields property (for instance, DashboardSqlDataSource.CalculatedFields for SQL data sources or DashboardExcelDataSource.CalculatedFields for Excel data sources).
To learn more about calculated fields, see the following topics.
- Calculated Fields - Overview
- WinForms Designer - Creating Calculated Fields
- Web Dashboard - Creating Calculated Fields
Example
The following code snippet shows how to create a new calculated field based on the values of the ‘UnitPrice’ and ‘Discount’ data fields, and add it to the existing DashboardSqlDataSource.
using DevExpress.DashboardCommon;
//...
CalculatedField priceWithDiscount = new CalculatedField("[UnitPrice] * (1 - [Discount])");
priceWithDiscount.DataMember = "SalesPerson";
priceWithDiscount.Name = "Price with discount";
sqlDataSource.CalculatedFields.Add(priceWithDiscount);
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the CalculatedField class.
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.