Fields provide data to display on a report page. ActiveReports has two types of fields; a bound or database field and a calculated field.
- Bound or Database field: A field where the value is returned by a query. See the Query dropdown in the Dataset Dialog for further information on queries in page reports and RDL reports.
- Calculated field: A field where the value is an expression created with functions, formulas and operators. Use the following instructions to add calculated fields in a report.
To create a calculated field in a Section Report
In a , once you connect to a data source, bound fields automatically appear under the Fields > Bound node in the Report Explorer. However, you have to add calculated fields manually under the Fields > Calculated node. The following steps guide you through the process.
- In the Report Explorer, expand the Fields node.
- Right-click the Calculated node and select Add. This action creates an unbound field with a default name like field1.
- In the Report Explorer, with field1 selected, go to the Properties Window and set a value for the field in the Formula property. For e.g., for a calculated field Inventory, in the Formula field, enter the expression =UnitsInStock - ReorderLevel.
You can change the name of the field in the Name property.
- Drag the field from the Calculated node onto the section of the report. This action creates a TextBox object, and sets its DataField property to the name of the calculated field.
Note: You can also add C# expressions in a Bound Field's DataField property to modify it. See
Add Field Expressions for more information.
To create a calculated field in a Page Report/RDL Report
In a or a , all fields irrespective of their type appear under the corresponding DataSet node in the Report Explorer. To create a calculated field, you can add the new field in the DataSet dialog.
The following steps guide you through the process.
Note: These steps assume that you have added a DataSet in your report. See
Add a Dataset for further information.
- In the Report Explorer, right-click the data set node and select Edit.
- In the DataSet dialog that appears, go to the Fields page and click the Add (+) button to add an empty field to the list.
- Under Name, enter the name of the field. By default it appears as Field1.
- Under Value, click the dropdown arrow and select <Expression...>, to open the Expression Editor dialog.
- In the Expression Editor dialog, create an expression you want to use as the value for the calculated field. For e.g., for a calculated field Cost, in the Formula field, enter the expression =[Quantity]*[Price]. See Expressions for further information.
- Click OK to close the Expression Editor and then the DataSet dialogs.
- From the Report Explorer, drag the calculated field from that now appears as a field under the DataSet node onto the . This action creates a TextBox object, and sets its Value property to the name of the calculated field expression.
See Also