This SSRS article shows how to calculate the running Total for a table report using a RunningValue function with an example. It is one of the important interview questions one might face.
To calculate the Running Total in SSRS, right-click on the Datasets folder to create a new DataSet. The below screenshot shows the data set that we use for this example.
We have designed a simple table report of Employee sales and formatted the font and colors. Please check the report review.
The Sql query that we used for this SSRS example is:
SELECT * FROM Employee
Calculate the Running Total in SSRS
Right-click on the sales column, choose the insert column, and then select the right option to create a new column on the right side of the sales. Name the header field Running Total. Next, right-click on the below empty cell and choose an expression to calculate the running Total.
- Please refer to Calculate Running Total in Grouped Report.
The reporting service has a RunningValue function to calculate the running Total, which accepts a numeric column, an aggregate function, and the dataset name. Here, we have chosen the sum aggregate function to find the Total or sum.
Write the below expression.
=RunningValue(Fields!Sales.Value, sum, "EmpDs")
Click OK to close the expression window and check the final report for any other formatting changes. If you go to the report preview now, you can see the running Total from table top to down.