CrosstabCount

Description

Counts the number of values returned by an expression in the values list of the crosstab. When the crosstab definition has more than one column, CrosstabCount can also count the number of the expression’s values for groups of column values.

NoteFor crosstabs only You can use this function only in a crosstab DataWindow object.

Syntax

CrosstabCount ( n {, column, groupvalue } )

Argument

Description

n

The number of the crosstab-values expression for which you want the total number of returned values.

column (optional)

The number of the crosstab column as it is listed in the Columns box of the Crosstab Definition dialog for which you want intermediate calculations.

groupvalue (optional)

A string whose value controls the grouping for the calculation. Groupvalue is usually a value from another column in the crosstab. To specify the current column value in a dynamic crosstab, rather than a specific value, specify @ plus the column name as a quoted string.

Returns

Long. Returns the number of values returned by expression n for all the column values or, optionally, for a subset of column values.

Usage

This function is meaningful only for the count of the values of the expression in a row in the crosstab. This means you can use it only in the detail band, not in a header, trailer, or summary band.

Null values are ignored and are not included in the count.

For more information about restricting the calculation to groups of values when the crosstab definition has more than one column, see Usage for CrosstabAvg.

NoteReviewing the expressions To review the expressions defined for the crosstab values, open the Crosstab Definition dialog box (select Design>Crosstab from the menubar).

Examples

Example 1

These examples all use the crosstab-values expressions shown below:

Count(emp_id for crosstab),Sum(salary for crosstab)

Example 2

This expression for a computed field in the crosstab returns the count of the employee counts (the first expression):

CrosstabCount(1)

Example 3

This expression for a computed field in the crosstab returns the count of the salary totals (the second expression):

CrosstabCount(2)

Example 4

The next two examples use a crosstab with two columns (year and quarter), a row (product), and the values expression Avg(sales for crosstab).

This expression for a computed field returns the count of the sales for each year:

CrosstabCount(1, 2, "@year")

Example 5

This expression for a computed field returns the count of all the sales in the row:

CrosstabCount(1)

For an example illustrating how the painter automatically defines a crosstab by creating computed fields using the Crosstab functions, see CrosstabAvg.

See also