Click to Rate and Give Feedback

  Switch on low bandwidth view
Community Content
In this section
Statistics Annotations (0)
Other versions are also available for the following:
SQL Server 2008 Books Online (June 2009)
RowNumber Function (Reporting Services)

Returns a running count of the number of rows for the specified scope.

RowNumber(scope)
scope

(String) The name of a dataset, data region, or group, or null (Nothing in Visual Basic), that specifies the context in which to evaluate the number of rows. Nothing specifies the outermost context, usually the report dataset.

RowNumber returns a running value of the count of rows within the specified scope, just as RunningValue returns the running value of an aggregate function. When you specify a scope, you specify when to reset the row count to 1.

scope cannot be an expression. scope must be a containing scope. Typical scopes, from the outermost to the innermost containment, are report dataset, data region, row groups or column groups.

To increment values across columns, specify a scope that is the name of a column group. To increment numbers down rows, specify a scope that is the name of a row group.

ms159225.note(en-us,SQL.100).gifNote:
Including aggregates that specify both a row group and a column group in a single expression is not supported.

Code Example

The following is an expression that you can use for the BackgroundColor property of a Tablix data region detail row to alternate the color of detail rows for each group, always beginning with White..

=IIF(RowNumber("GroupbyCategory") Mod 2, "White", "PaleGreen")
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker