Report Builder Functions - RunningValue Function

Returns a running aggregate of all non-null numeric values specified by the expression, evaluated for the given scope.

Note

You can create and modify paginated report definition (.rdl) files 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.

Syntax


RunningValue(expression, function, scope)  

Parameters

expression
The expression on which to perform the aggregation, for example, [Quantity].

function
(Enum) The name of the aggregate function to apply to the expression, for example, Sum. This function cannot be RunningValue, RowNumber, or Aggregate.

scope
(String) A string constant that is the name of a dataset, data region, or group, or null (Nothing in Visual Basic), that specifies the context in which to evaluate the aggregation. Nothing specifies the outermost context, usually the report dataset.

Return Type

Determined by the aggregate function that is specified in the function parameter.

Remarks

The value for RunningValue resets to 0 for each new instance of the scope. If a group is specified, the running value is reset when the group expression changes. If a data region is specified, the running value is reset for each new instance of the data region. If a dataset is specified, the running value is not reset throughout the entire dataset.

RunningValue cannot be used in a filter or sort expression.

The set of data for which the running value is calculated must have the same data type. To convert data that has multiple numeric data types to the same data type, use conversion functions like CInt, CDbl or CDec. For more information, see Type Conversion Functions.

Scope cannot be an expression.

Expression can contain calls to nested aggregate functions with the following exceptions and conditions:

Examples

The following code example provides a running sum of the field named Cost in the outermost scope, which is the dataset.

=RunningValue(Fields!Cost.Value, Sum, Nothing)  

The following code example provides a running sum of the field named Score in the dataset named DataSet1.

=RunningValue(Fields!Score.Value,sum,"DataSet1")  

The following code example provides a running sum of the field named Traffic Charges in the outermost scope.

=RunningValue(Fields!Traffic Charges.Value, Sum, Nothing)  

See Also

Expression Uses in Reports (Report Builder and SSRS)
Expression Examples (Report Builder and SSRS)
Data Types in Expressions (Report Builder and SSRS)
Expression Scope for Totals, Aggregates, and Built-in Collections (Report Builder and SSRS)