FlexReport for WPF | ComponentOne
Fields and Custom Fields / Calculated Field
In This Topic
    Calculated Field
    In This Topic

    In order to create fields that do not use raw data, Calculated fields are the best option. Calculated fields contain expressions that are evaluated at run-time. They are used to generate those data values that are not stored in the data base.

    Add Predefined Calculated Field

    Some predefined expressions are available in the dropdown of Calculated Fields. To add such fields, follow the steps below:

    1. Create a new FlexReport in FlexReportDesigner.
    2. From Insert tab, add two Calculated fields  - 'Date Created' and 'Page n of m', in the PageFooter section:
      Add calculated field in Designer
    3. Note the expressions in these calculated fields in the design area.

      Calculated field
    4. Preview the report.

      Preview field in the Designer

    Add Custom Calculated Field

    To define a Calculated field and add the field in the FlexReport Designer application:

    1. Create a new report.    
    2. Bind the report with 'Orders Details' Table.    
    3. In Group Header, add a Text field 'Total' to display label for the total price.
    4. Go to Data tab, and right-click the Main data source and select Add Calculated Field. VBScript Editor appears.
    5. In the VBScript Editor, write the following expression:

      Quantity*UnitPrice

    6. Drop the above mentioned Calculated field as shown.

      Add TotalPrice field in the Designer.
    7. Preview the report.

      Preview report