#### Count

Function

- Count(array_variable);
- Count(field_variable);
- Count(field_variable, groupby);

Description

This function is used to count the number of a group of values referred to by the first argument. The second argument, if there is one, returns the group by field name.

Arguments

- field_variable
  field_variable is a special variable in Formula. It refers to a group of values of a database field or of a formula field.
- array_variable
  array_variable refers to an array.
- groupby
  groupby can be a constant String to indicate the groupby field name, or a field variable on which the grouping occurs, or a parameter variable that can accept a different value before each execution of a report.

Return type

Returns a Number value.

Examples

- `Number x = Count([1.0, 2.0, 3.0, 4.5, 45.0, 67.0]).`
- `Number x[6] = [1.0, 2.0, 3.0, 4.5, 45.0, 67.0];
  Number y = Count(x).`
- `Number x = Count(["str1","str2","str3","str4","str5","str6"]).`
- `Number x = Count(@dbfield).`
- `Number x = Count(@formula).`
- `Number x = Count(@dbfield, "group_field").`
- `Number x = Count(@formula, @"group_field").`
- `Number x = Count(@dbfield, @parameter).`

Note: If a field_variable is assigned to a variable, for example X, the variable X will lose the characteristic of representing a group of values. The following formula will then be treated as in correct.

`Number x = @dbfield;
Number y = Count(x); // system will prompt you that there is no such kind of function.`