This document demonstrates how to add a calculated field to a report. The main purpose of calculated fields is to perform pre-calculations (of virtually any level of complexity) over data fields. To learn how to easily perform simple calculations within a single data field, refer to Add Totals to a Report.

In the Report Designer, a calculated field is similar to an ordinary data field (e.g. you can bind controls to it, and group, sort and filter your report against it).

To add a calculated field to your report, follow the instructions below.

  1. To create a calculated field, in the Field List, right-click any data member, and on the invoked menu, choose Add Calculated Field.

  2. In the Field List, select the created field to show its properties in the Property Grid. Among these options, make sure to change the Field Type property to an appropriate value.

  3. Now, let's create an expression for the calculated field.

    Click the ellipsis button in the Expression section, to invoke the Expression Editor. You can also invoke this dialog by right-clicking your calculated field within the Field List and selecting Edit Expression...

    Click Fields to see the field list. Double-click field names to add them to the expression string. Use the toolbar to add operators between field names.

    NoteNote

    Note that it's also possible to employ parameters in a calculated field's expression.

    To close the dialog and save the expression, click OK.

  4. Finally, drag the calculated field from the Field List onto the required band, just like an ordinary data field.

The report with a calculated field is now ready. Switch to the Preview Tab, and view the result.

Expand imageSee Also