Calculate the Running Count in SSRS

This article explains how to calculate the running count in SSRS using RunningValue in a particular group or complete table with an example.

To Calculate the Running Count in the SSRS demonstration, we use the Employee table below, which has 15 records grouped by Occupation. Next, we used the Count function to display the Count of Education and YearlyIncome columns per group and table. The image below shows the records in the Table report.

The Count function expressions that we used in the below report are:

Count Per Group

=Count(Fields!Education.Value)
=Count(Fields!YearlyIncome.Value)

Count Per Table

=Count(Fields!Education.Value, "Tablix1")
=Count(Fields!YearlyIncome.Value, "Tablix1")
Source Table

How do we calculate the running count in SSRS?

Let me add a new column to the right side of the Education and Income and name the headers to Edu Run Cat and Inc Run Cnt. Next, right-click the textbox under the Inc Run Cnt and choose the Expression. To understand the report, I suggest you refer to the Count, Charts, Table, Grouping, and Format Table articles in SSRS.

Choose the Expression

It opens the following expression window to calculate the running count. To get the same, we have to use the aggregate Count function. The SSRS RunningValue code below calculates the running count of the yearly income for each Occupation group.

=RunningValue(Fields!YearlyIncome.Value, Count, "Occupation")
RunningValue expression to Calculate Running Count in SSRS

Similarly, right-click the Edu Run Cat textbox and write the code to find the education running count for each Occupation. For more available functions >> Click Here!

=RunningValue(Fields!Education.Value, Count, "Occupation")
RunningValue expression to Calculate Running Count of string column in SSRS

Please click the preview tab to see the running count of the Employee Education and Yearly income for each Occupation.

Calculate Running Count in SSRS report preview

Let me create two more new SSRS columns and name them Edu Full Cnt and Inc Full Cnt to calculate the running count for the whole table. To do so, you must replace the group name (“Occupation”) with the table name (“Tablix1”) or DataSet name (“DSet”). First, add the below RunningValue expression for the textbox under the Edu Full Cnt header.

=RunningValue(Fields!Education.Value, Count, "DSet")
SSRS expression to Calculate Running Count per table

Similarly, write the following expression for the textbox under the Inc Full Cnt header. The below code will find the running count of the yearly income in a table.

=RunningValue(Fields!YearlyIncome.Value, Count, "DSet")

The SSRS report below calculates the running count of the education and yearly income for each occupation group and the employee table.

Calculate Running Count in SSRS report preview