|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
How to: Create Data Columns that Display Expressions
A data table in a dataset can contain columns in which the value is calculated rather than read from the database. For example, in an order details record, it might make sense to define an ExtendedPrice column by multiplying the quantity times the price, rather than actually storing the total in the record. Calculated columns can also add or count values in child records and filter other records. You can define calculated columns using expressions.
The syntax of the expression consists of standard operators. You can reference a data value using its column name (as you would in an SQL statement) and include aggregate functions such as Count.
For example, the expression for an ExtendedPrice column based on the UnitPrice times Quantity columns of the current record might simply be:
UnitPrice * Quantity
To refer to columns in child tables, you can use the reserved word Child, followed by the name of the column. For example, the following expression returns the average value of the Price column in all related child records:
For more information, see theproperty.
You can create expression columns in the Dataset Designer. For more information about creating columns, see .
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see.
To create column expressions in the Dataset Designer
Open your dataset in the Dataset Designer. For more information, see.
In the data table that you want, select the column you want to add the expression to, or add a new column to the table. For more information, see.
In the Properties window, enter an expression in the Expression property.