How to Add a Serial Number to a Matrix in Bold Reports
To add a sequential serial number to each group in a matrix in the Bold Reports Report Designer, select the text box in the matrix’s row-group cell and enter =RunningValue(Fields!ProductID.Value, CountDistinct, "DataSet1"), using the field your row group is grouped on. RunningValue with CountDistinct advances the number by one for each new distinct value, giving one number per group.
When to use this
Use this when you need a sequential row number or group counter inside a matrix (tablix). For example, to label each distinct row group 1, 2, 3. RDL (Report Definition Language) reports support this through the RunningValue aggregate function, which returns a running aggregate of a value within a scope you specify.
The number is correct as one per group only when the field you pass to CountDistinct is the field the row group is grouped on. That field has exactly one distinct value per group, so the counter advances by exactly one each time a new group starts. If you pass a different field, the number follows that field’s distinct values, not the groups.
Steps
-
Open the report in the Bold Reports Report Designer.
-
Locate the matrix cell where you want the serial number to appear, and click it to select it.
-
Open the Expression editor for that cell, from the cell’s properties or its right-click context menu.
-
Enter the following expression, then click OK.
=RunningValue(Fields!ProductID.Value, CountDistinct, "DataSet1")RunningValuereturns a running aggregate within the scope you name.CountDistinctcounts distinctProductIDvalues, which produces a sequential number for each new group. ReplaceProductIDandDataSet1with your own field and dataset names. -
Save the report, then click Preview to see the serial number column.
Result
When the field in CountDistinct is the row group’s grouping field, the matrix shows a serial number that increments 1, 2, 3 for each group. Repeated values inside a single group do not change the number, because CountDistinct removes duplicates before counting. The value is recalculated each time the report runs.