COUNT command
Concept Information
Counts the total number of records in the current view, or only those records that meet the specified condition.
Syntax
COUNT <IF test> <WHILE test> <FIRST range|NEXT range>
Parameters
Name | Description |
---|---|
IF test optional |
A conditional expression that must be true in order to process each record. The command is executed on only those records that satisfy the condition. Note The IF parameter is evaluated against only the records remaining in a table after any scope parameters have been applied (WHILE, FIRST, NEXT). |
WHILE test optional |
A conditional expression that must be true in order to process each record. The command is executed until the condition evaluates as false, or the end of the table is reached. Note If you use WHILE in conjunction with FIRST or NEXT, record processing stops as soon as one limit is reached. |
FIRST range | NEXT range optional |
The number of records to process:
Use range to specify the number of records to process. If you omit FIRST and NEXT, all records are processed by default. |
Analytics output variables
Name | Contains |
---|---|
COUNTn |
The record count calculated by the command.
|
Examples
Storing COUNT1
The result of the COUNT command is stored in the COUNT1 output variable. You can retrieve and store this value in a user-defined variable.
The COUNT command overwrites the COUNT1 variable each time it is executed, so the value needs to be stored in a user-defined variable before the command is executed for the second time after the filter is applied to the table:
OPEN CustomerAddress
COUNT
TotalRec = COUNT1
SET FILTER TO ModifiedDate > '20100101'
COUNT
TotalFilteredRec = COUNT1
Remarks
When to use COUNT
Use the COUNT command to count the number of records in an Analytics table, or to count the number of records that meet a particular test condition. If no test is specified, the total number of records in the Analytics table is displayed.
How filters affect COUNT
If a filter has been applied to a view, the command counts the number of records remaining in the view after the filtering condition has been applied.