Datatable compute attributes

Source: Internet
Author: User
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");
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.