# table.FIELD_STATISTICS Function

Syntax

V Field_Statistics(C Expr,P stats)

Arguments

Expr

An expression or value that selects some or all of the fields in the table.

stats

The name of the Statistics dot variable that will receive the answers.

Description

Collects statistics for passed in expression/field.

Discussion

The <TBL>.FIELD_STATISTICS() method computes statistics (first value, last value, minimum value, count, total, average, standard deviation and variance) for Expression, for all of the currently selected records in the table referenced by <TBL>. The statistics are stored in a Statistics dot variable. For example, the command:

`tbl.field_statistics("amount_due", answer)`

Dot Variable
Description
.count

Number of records in current index/query list. Created for All Expression Types.

.minimum

Minimum value in field/expression. Created for All Expression Types.

.maximum

Maximum value in field/expression. Created for All Expression Types.

.first

Value of field/expression in first record in current selection of records. Created for All Expression Types.

.last

Value of field/expression in last record in current selection of records. Created for All Expression Types.

.total

Total of field/expression for all records in current selection of records. Created for Numeric Expression Types.

.average

Average of field/expression for all records in current selection of records. Created for Numeric Expression Types.

.standard

Standard deviation of field/expression for all records in current selection of records. Created for Numeric Expression Types.

.variance

Variance of field/expression for all records in current selection of records. Created for Numeric Expression Types.

### Example

This script is attached to a button on a form. It computes the field statistics for the amount_due field.

```dim tbl as P
tbl = table.current()

If you wanted to compute statistics for just customers in "MA".

```dim tbl as P
tbl = table.current()
query.filter = "state = 'ma'"
i = tbl.query_create()