RowNumber Function (Report Builder and SSRS)
Returns a running count of the number of rows for the specified scope.
You can create and modify report definitions (.rdl) in Report Builder and in Report Designer in SQL Server Data Tools. 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 (SSRS) on the Web at microsoft.com.
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.
Including aggregates that specify both a row group and a column group in a single expression is not supported.
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")