RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TAggregateField.Expression Property

Specifies the formula used to calculate the aggregate value.

Pascal
property Expression: String;
C++
__property AnsiString Expression;

Set Expression to indicate how aggregate values should be calculated. Expression contains an expression that includes one or more of the summary operators in the following table:

Operator 
Use 
Sum  
Totals the values for a numeric field or expression.  
Avg  
Computes the average value for a numeric or date-time field or expression.  
Count  
Specifies the number of non-blank values for a field or expression. Use count(*) to count the number of records in a dataset or subgroup.  
Min  
Indicates the minimum value for a string, numeric, or date-time field or expression.  
Max  
Indicates the maximum value for a string, numeric, or date-time field or expression.  
Sum(Qty * Price)  
{legal -- summary of an expression on fields }  
Max(Field1) - Max(Field2)  
{legal -- expression on summaries }  
Avg(DiscountRate) * 100  
{ legal -- expression of summary and constant }  
Min(Sum(Field1))  
{ illegal -- nested summaries }  
Count(Field1) - Field2  
{ illegal -- expression of summary and field }  

The summary operators act on field values or on expressions built from field values using the same operators you use to create filters. (You can't nest summary operators, however.) You can create expressions by using operators on summarized values with other summarized values, or on summarized values and constants. However, you can't combine summarized values with field values, because such expressions are ambiguous (there is no indication of which record should supply the field value.) These rules are illustrated in the following expressions:

Note: To specify the set of records summarized by this expression, use the GroupingLevel property.
 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!