Last Function (Reporting Services)
Returns the last value in the given scope of the specified expression.
Syntax
Last(expression, scope)
Parameters
expression
(Variant or Binary) The expression on which to perform the aggregation, for example, =Fields!Fieldname.Value. This expression cannot contain aggregate functions.scope
(String) (Optional) The name of a dataset, data region, or group that contains the report items to which to apply the function. If scope is not specified, the current scope is used. For more information, see Using Built-in Report and Aggregate Functions in Expressions (Reporting Services) and Calculating Totals and Other Aggregates (Reporting Services).
Return Type
Determined by the type of expression.
Remarks
The Last function returns the final value in a set of data after all sorting and filtering have been applied at the specified scope.
The Last function cannot be used in group filter expressions with anything except the current (default) scope.
You can also use Last in a page header to return the last value from the ReportItems collection for a page in order to produce dictionary-style headings that display the first and last entries on a page.
The value of scope cannot be an expression and must refer to the current scope or a containing scope.
Example
The following code example returns the last product number in the Category group of a data region.
=Last(Fields!ProductNumber.Value, "Category")
See Also
Concepts
Using Expressions (Reporting Services)
Using Built-in Report and Aggregate Functions in Expressions (Reporting Services)