Back to Devexpress

CalculatedField Class

dashboard-devexpress-dot-dashboardcommon-b3df99bc.md

latest4.8 KB
Original Source

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.v25.2.Core.dll

NuGet Package : DevExpress.Dashboard.Core

Declaration

csharp
public class CalculatedField :
    INamedItem,
    INameContainer,
    ISupportPrefix
vb
Public Class CalculatedField
    Implements INamedItem,
               INameContainer,
               ISupportPrefix

The following members return CalculatedField objects:

Remarks

The DevExpress Dashboard allows you to create calculated fields for the following data source types:

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.

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.

csharp
using DevExpress.DashboardCommon;
//...

            CalculatedField priceWithDiscount = new CalculatedField("[UnitPrice] * (1 - [Discount])");
            priceWithDiscount.DataMember = "SalesPerson";
            priceWithDiscount.Name = "Price with discount";
            sqlDataSource.CalculatedFields.Add(priceWithDiscount);
vb
Imports DevExpress.DashboardCommon
'...

            Dim priceWithDiscount As New CalculatedField("[UnitPrice] * (1 - [Discount])")
            priceWithDiscount.DataMember = "SalesPerson"
            priceWithDiscount.Name = "Price with discount"
            sqlDataSource.CalculatedFields.Add(priceWithDiscount)

Inheritance

Object CalculatedField

See Also

CalculatedField Members

Expression Constants, Operators, and Functions

DevExpress.DashboardCommon Namespace