SSRS: RunningValue() to get Cumulative Totals
If you have a SSRS (SQL Server Reporting Services) report, and you want to aggregate values on a column, the function RunningValue() is what you would use.
The function takes 3 parameters, the field you want to “run the value” on, the function you want to run on it (Sum for example), and then the scope. The scope can be “Nothing” ex: RunningValue(Fields!Blah.Value,Sum,Nothing) but where the scope really comes into play is when you want to group by given fields in your row.
So if you want to group by say, salesperson, and run their values by day of their sales for a month to date total, you would have
Salesperson Date Daily Sales Month To Date Sales
——————————————————————————-
Homer Simpson
07/01/2007 50 50
07/02/2007 43 93
Bart Simpson
07/01/2007 5 5
07/02/2007 8 13
How you achieve this is: on the row with the salesperson, there is a group defined if you right click. Look at the group name, by default it is usually table1_detailsGroup or something similar (if you used the wizard).
Then, the column for the Month to Date Sales would have the expression
=RunningValue(Fields!DailySales.Value,Sum,”table1_detailsGroup”)
Where you can see the scope is now defined as the table group name as a string.
Simlar Posts
- SSRS Exporting Report to Excel – Keep Formatting on Export
- SSRS and SSAS Formatting Dates
- SQL Server Reporting Services: Quick way to get 10 digit year (all the zero’s) using String.Format
- SSRS Exporting Report to Excel – Keep Formatting on Export Round 2
- Reporting Services Scripter: Sync Reporting Services Instances and Objects
