Expressions Overview
- 4 minutes to read
Use expressions to accomplish the following tasks:
- Retrieve data
- Format data values
- Create calculated fields
- Calculate summaries
- Hide controls or change their appearance
- Specify conditions for data source queries
- Display Average Values in Charts
- Group Numbering by Index
Expression and Expression Binding Object
The expression binding technique is a versatile mechanism that allows you to flexibly set values for most of the properties of the report controls. An expression can include data fields, constants, functions, report parameters, and property values of other controls.
An expression is a string assigned to the ExpressionBinding object’s Expression property. A report control or a report band stores expression binding objects in a collection accessible with the ExpressionBindings property.
You can specify expressions in Expressions or ExpressionsAdvanced data binding mode. For more information, review the following help topic: Data Binding Modes.
Expression Editor
The Report Designer’s Expression Editor has a graphical interface that allows you to create and edit expressions.
Use one of the following ways to invoke the Expression Editor:
Select a report, band, or control. The
f
button appears next to the selection. Click this button to invoke the Expression Editor.In the Properties window, if an expression can be set for a property, the
f
button appears near the value editor. Click (in the End-User Report Designer) or double-click (in the Visual Studio Report Designer) this button to invoke the Expression Editor.The
f
button changes its color to blue to indicate that an expression is set for a property.In the Visual Studio Report Designer, the Properties window has the Expressions tab that lists properties for which expressions can be set. An ellipsis button (
...
) appears in the value editor when you select a property. Click the ellipsis button to invoke the Expression Editor.
The Editor lists all properties for which you can specify an expression. The list of properties is hidden when you specify a parameter or calculated field’s expression.
Click a property to specify an expression.
An f
icon appears next to a property where an expression is set. Additionally, an asterisk (*
) appears if an expression is modified.
The Editor highlights an expression’s syntax and supports intelligent code completion (which suggests functions and available data elements as you type).
The Expression Editor displays all the errors it finds in the specified expression.
The Editor lists a tree with language elements and items that you can use in an expression.
Note
You should reference report item values with caution. We do not guarantee that by the time an expression is parsed, the item referenced in an expression is already displayed and has the correct value.
FilterString Editor
You can use the Report Designer’s FilterString Editor to specify the FilterString property of a report, XRCrossTab, or XRChart Series.
The FilterString Editor‘s visual interface allows you to use an unlimited number of conditions and combine them with logical operators to create filter criteria. You can also switch to Text mode and type a filter string.
The FilterString Editor highlights an expression’s syntax and supports intelligent code completion (which suggests functions and available data elements as you type).
The following limitation applies to the Visual Studio Report Designer for .NET/.NET Core: the FilterString Editor does not show display names for enumerations. If you want to use an enumeration value in a filter condition, specify the value’s associated constant in this condition explicitly.
Expression Syntax
An expression can include field names, constants, operators, functions, data fields, and parameters.
Refer to the following topic for more information: Expression Language.
You can create custom functions to implement additional functionality. For more information, review the following help topics: