Parameters
- Expression
-
The expression to be calculated.
- Filter
-
Filter of the rows to be computed in the expression.
Return Value And set it to the calculation result.
ExpressionParameters must be aggregated. For example, the following is a legal expression:
Count (Quantity)
However, the following expression is invalid:
Sum (quantity * unitprice)
If you must perform operations on two or more columns, create a datacolumn, set its expression attribute to an appropriate expression, and then use an aggregate expression for the result column. In this case, assume that there is a datacolumn named "Total" and the expression attribute is set:
"Quantity * unitprice"
The expression parameter of the compute method will be:
Sum (total)
Second ParameterFilterDetermine which rows are used in the expression. For example, if the table contains a date column named "coldate", you can use the following expressions to restrict these rows:
Coldate> 1/1/99 and coldate <17/1/99
For rules on creating expressions for these two parameters, see the datacolumn. Expression attribute.
The following example sums the values of the columns named "Total" (total) for the salesperson who identifies number 5.
Private Void Computebysalessalesid (Dataset dataset)
{
Datatable table;
Table=Dataset. Tables ["Orders"];
Sumobject=Table. Compute ("Sum (total)","Empid = 5");
}