Edit Expression (Report Designer)
Use the Expression Editor to write an expression in Microsoft Visual Basic. The Expression Editor includes a code window, a category tree, category items, and a description pane. You can open the Expression Editor for the following items:
- A text box on a report.
- A property in the Properties page.
- A Groups tab on data region properties.
- A Sorting tab on data region properties.
- A Filter tab for datasets, data regions, or data region groupings.
- A document map label on a data region group.
- A parent group on a data region group.
- A query string on a dataset.
- A parameter value for a query.
- A parameter value for a report.
- A connection string for a data source.
Some property pages (for example, Table Properties (Sorting Tab, Report Designer)) allow you to create multiple expressions that are combined during report processing, but the Expression Editor works with a single expression at a time.
You can open the Expression Editor by right-clicking a text box, by choosing <Expression> in the values list of a property, or by clicking the Expression (Fx) button where available on a dialog box. You can use expressions to set many properties, including color, font, and borders to name a few.
The Expression Editor is context-sensitive; the category items and descriptions change in response to the expression category you are working with. It supports IntelliSense, statement completions, and syntax coloring so that you can easily detect syntax errors. You can move and resize the Expression Editor if you want a larger work surface.
For more information including examples, see Expression Examples in Reporting Services and Using Parameters in Expressions.
Expression Constructs
The expressions you create begin with an equal sign (=) and include constants, global values, fields, and other elements. The following list describes the categories and parts of an expression.
Constants
Select the Constants node to define expressions that include a constant value. Constants are used to specify color, font, and enumerations.Not all items will support expressions that can be set to a constant. If a property cannot be set to constant value, the description provides this information.
- Globals
Provides a list of the items in the global collection that you can use in an expression. For more information, see Using Global Collections in Expressions (Reporting Services).
- Parameters
Provides a list of parameters. Both query parameters and report parameters are available.
- Fields
Displays a list of fields that can be used in the expression. The list varies depending on the property. Double-click a field to copy the field to the Expression box. Alternatively, you can drag a field to the Expression box.
- Datasets
Provides a list of available datasets and shows the fields that are members of the dataset.
- Operators
Displays the operators you can include in a calculation or string manipulation.
- Common Functions
Displays common functions, grouped by type (for example, text, date & time, and so on).
Options
Code window
Use the code window in the top pane to type an expression. When you open the Expression Editor, the code window contains the field expression. You can replace or revise the expression. You can paste in functions, operators, constants, fields, parameters, and items from the global collections. The code window reflects the modifications as you go.A wavy red underline indicates a syntax error. Hover over the underlined text to see the error message.
When you type in global collection terms followed by a punctuation separator, you will see a drop-down list of available properties, members, or methods. From the drop-down list, you can type the first few characters followed by a tab to autofill the selection.
- Category tree
Displays categories of expressions. Choosing a category establishes a context for creating an expression. For example, selecting Aggregate functions displays AVG, Count, and other functions that you can incorporate into the expression.
- Descriptions, samples, or member list
Depending on the category item you select, the third pane contains a description, a sample expression, or a list of members.
See Also
Reference
Other Resources
Using Expressions in Reporting Services
Reporting Services Tutorials
Formatting Report Items
Formatting Numeric and Date Values in a Report