Bewerken

Delen via


Parameters collection references in a paginated report (Report Builder)

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

Paginated report parameters are one of the built-in collections you can reference from an expression. By including parameters in an expression, you can customize report data and appearance based on choices a user makes. Expressions can be used for any report item property or text box property that provides the (*Fx) or <Expression> option. Expressions are also used to control report content and appearance in other ways. For more information, see Expression examples (Report Builder).

When you compare parameter values with dataset field values at run time, the data types for the two items you're comparing must be the same. Report parameters can be one of the following types: Boolean, DateTime, Integer, Float, or Text, which represents the underlying data type String. If necessary, you might have to convert the data type of the parameter value to match the dataset value. For more information, see Data types in expressions (Report Builder).

In order to include a parameter reference in an expression, you must understand how to specify the correct syntax for the parameter reference. The syntax varies depending on whether the parameter is a single-value or multivalue parameter.

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.

Use a single-valued parameter in an expression

The following table shows examples of the syntax to use when you include a reference to a single-value parameter of any data type in an expression.

Example Description
=Parameters! <ParameterName> .IsMultiValue Returns False.

Checks if a parameter is multivalue. If True, the parameter is multivalue and it's a collection of objects. If False, the parameter is single-value and is a single object.
=Parameters! <ParameterName> .Count Returns the integer value 1. For a single-value parameter, the count is always 1.
=Parameters! <ParameterName> .Label Returns the parameter label, frequently used as the display name in a list of available values.
=Parameters! <ParameterName> .Value Returns the parameter value. If the Label property wasn't set, this value appears in the list of available values.
=CStr(Parameters! <ParameterName> .Value) Returns the parameter value as a string.
=Fields(Parameters! <ParameterName> .Value).Value Returns the value for the field that has the same name as the parameter.

For more information about using parameters in a filter, see Add dataset filters, data region filters, and group filters (Report Builder).

Use a multivalue parameter in an expression

The following table shows examples of the syntax to use when you include a reference to a multivalue parameter of any data type in an expression.

Example Description
=Parameters! <MultivalueParameterName> .IsMultiValue Returns True or False.

Checks if a parameter is multivalue. If True, the parameter is multivalue and is a collection of objects. If False, the parameter is single-valued and is a single object.
=Parameters! <MultivalueParameterName> .Count Returns an integer value.

Refers to the number of values. For a single-value parameter, the count is always 1. For a multivalue parameter, the count is 0 or more.
=Parameters! <MultivalueParameterName> .Value(0) Returns the first value in a multivalue parameter.
=Parameters! <MultivalueParameterName> .Value(Parameters! <MultivalueParameterName> .Count-1) Returns the last value in a multivalue parameter.
=Split("Value1,Value2,Value3",",") Returns an array of values.

Create an array of values for a multivalue String parameter. You can use any delimiter in the second parameter to Split. This expression can be used to set defaults for a multivalue parameter or to create a multivalue parameter to send to a subreport or drillthrough report.
=Join(Parameters! <MultivalueParameterName> .Value,", ") Returns a String that consists of a comma-delimited list of values in a multivalue parameter. You can use any delimiter in the second parameter to Join.

For more information about using parameters in a filter, see Report parameters (Report Builder and Report Designer).