Export (0) Print
Expand All

Using Built-in Collections in Expressions (Report Builder 3.0 and SSRS)

In an expression in a report, you can include references to the following built-in collections: ReportItems, Parameters, Fields, DataSets, DataSources, Variables, and built-in fields for global information such as the report name. Not all collections appear in the Expression dialog box. The DataSets and DataSources collections are available only at run-time for published reports on a report server. The ReportItems collection is collection of text boxes in a report region, for example, the text boxes on a page or in a page header.

For more information, see Expressions (Report Builder 3.0 and SSRS).

NoteNote

You can create and modify report definitions (.rdl) in Report Builder 3.0 and in Report Designer in Business Intelligence Development Studio. Each authoring environment provides different ways to create, open, and save reports and related items. For more information, see Designing Reports in Report Designer and Report Builder 3.0 (SSRS) on the Web at microsoft.com.

The following table lists the built-in collections available when you write an expression. Each row includes the case-sensitive programmatic name for the collection, whether you can use the Expression dialog box to interactively add a reference to the collection, an example, and a description that includes when the collection values are initialized and available for use.

Built-in Collection

Category in the Expression dialog box

Example

Description

Globals

Built-in Fields

=Globals.ReportName

- or -

=Globals.PageNumber

Represents global variables useful for reports, such as the report name or page number. Always available.

For more information, see Using Built-in Globals and Users References (Report Builder 3.0 and SSRS).

User

Built-in Fields

=User.UserID

- or -

=User.Language

Represents a collection of data about the user running the report, such as the language setting or the user ID. Always available.

For more information, see Using Built-in Globals and Users References (Report Builder 3.0 and SSRS).

Parameters

Parameters

=Parameters("ReportMonth").Value

- or -

=Parameters!ReportYear.Value

Represents the collection of report parameters, each of which can be single-value or multivalue. Not available until processing initialization is complete. For more information, see Using Parameters Collection References (Report Builder 3.0 and SSRS).

Fields(<Dataset>)

Fields

=Fields!Sales.Value

Represents the collection of fields of the dataset that are available to the report. Available after data is retrieved from a data source into a dataset. For more information, see Using Dataset Fields Collection References (Report Builder 3.0 and SSRS).

DataSets

Not Displayed

=DataSets("TopEmployees").CommandText

Represents the collection of datasets referenced from the body of a report definition. Does not include data sources used only in page headers or page footers. Not available in local preview. For more information, see Using DataSources and DataSets Collection References (Report Builder 3.0 and SSRS).

DataSources

Not Displayed

=DataSources("AdventureWorks").Type

Represents the collection of data sources referenced from within the body of a report. Does not include data sources used only in page headers or page footers. Not available in local preview. For more information, see Using DataSources and DataSets Collection References (Report Builder 3.0 and SSRS).

Variables

Variables

=Variables!CustomTimeStamp.Value

Represents the collection of report variables and group variables. For more information, see Using Report and Group Variables Collections References (Report Builder 3.0 and SSRS).

ReportItems

Not Displayed

=ReportItems("Textbox1").Value

Represents the collection of text boxes for a report item. This collection can be used to summarize items on the page for including in a page header or page footer. For more information, see Using the ReportItems Collection References (Report Builder 3.0 and SSRS).

To refer to a collection from an expression, use standard Microsoft Visual Basic syntax for an item in a collection. The following table shows examples of collection syntax.

Syntax

Example

Collection!ObjectName.Property

=Fields!Sales.Value

Collection!ObjectName("Property")

=Fields!Sales("Value")

Collection("ObjectName").Property

=Fields("Sales").Value

Collection("Member")

=User("Language")

Collection.Member

=User.Language

If you want to pass built-in collections into a custom assembly for processing, you must add an assembly reference in your code project to the assembly that defines the built-in collections and access the correct namespace. Depending on whether you are developing the custom assembly for a report that is run on a report server (server report) or a report that is run locally in a .NET application (local report), the assembly you need to reference is different. See below for details.

  • Namespace: Microsoft.ReportingServices.ReportProcessing.ReportObjectModel

  • Assembly (local report): Microsoft.ReportingServices.ProcessingObjectModel.dll

  • Assembly (server report): Microsoft.ReportViewer.ProcessingObjectModel.dll

Since the content of the Fields and ReportItems collections can change dynamically at runtime, you should not hold onto them across calls into the custom assembly (for example, in a member variable). The same recommendation applies generally to all built-in collections.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft