แก้ไข

แชร์ผ่าน


Built-in collections in expressions in a paginated report (Report Builder)

Applies to:  Microsoft Report Builder (SSRS)  Power BI Report Builder  Report Designer in SQL Server Data Tools

In an expression in a paginated 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. The DataSets and DataSources collections are available only at run-time for published reports on a report server. The ReportItems collection is a 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).

Note

You can create and modify paginated report definition (.rdl) files in Microsoft Report Builder, Power BI Report Builder, and in Report Designer in SQL Server Data Tools.

Understand built-in collections

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. The name is there whether you can use the Expression dialog 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 Built-in globals and users references (Report Builder).
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 Built-in globals and users references (Report Builder).
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 Parameters collection references (Report Builder).
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 Dataset fields collection references (Report Builder).
DataSets Not Displayed =DataSets("TopEmployees").CommandText Represents the collection of datasets referenced from the body of a report definition. Doesn't include data sources used only in page headers or page footers. Not available in local preview. For more information, see DataSources and dataSets collection references (Report Builder).
DataSources Not Displayed =DataSources("AdventureWorks2022").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 DataSources and dataSets collection references (Report Builder).
Variables Variables =Variables!CustomTimeStamp.Value Represents the collection of report variables and group variables. For more information, see Report and group variables collections references (Report Builder).
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 ReportItems collection references (Report Builder).

Using Collection Syntax in an Expression

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