CountRows Function (Report Builder 3.0 and SSRS)

Returns the number of rows in the specified scope, including rows with null values.

Note

You can create and modify report definitions (.rdl) in Report Builder 3.0 and in Report Designer in Business Intelligence Development Studio. Each authoring environment provides different ways to create, open, and save reports and related items. For more information, see Designing Reports in Report Designer and Report Builder 3.0 (SSRS) on the Web at microsoft.com.

Syntax

CountRows(scope, recursive)

Parameters

  • scope
    (String) The name of a dataset, data region, or group that contains the report items to count.

  • recursive
    (Enumerated Type) Optional. Simple (default) or RdlRecursive. Specifies whether to perform the aggregation recursively.

Return Type

Returns an Integer.

Remarks

CountRows counts all rows in the specified scope, including rows that have null values.

The value of scope cannot be an expression and must refer to the current scope or a containing scope.

For more information, see Aggregate Functions Reference (Report Builder 3.0 and SSRS) and Understanding Expression Scope for Totals, Aggregates, and Built-in Collections (Report Builder 3.0 and SSRS).

For more information about recursive aggregates, see Creating Recursive Hierarchy Groups (Report Builder 3.0 and and SSRS).

Example

The following code example shows an expression that calculates the number of rows in a row group named GroupbyCategory (based on the expression [Category]).

="Number of rows: " & CountRows("GroupbyCategory")