Totaling on a calculated field not working for me!

Posted by: jww on 4 August 2017, 3:02 pm EST

  • Posted 4 August 2017, 3:02 pm EST

    As a novice user, I have been trying to create and total a calculated field as shown in Active Reports help "Using Formulas and Calculated Fields". I keep getting an error on type mismatch, when I include in the datafield of the detail level calculated field, "=BasisIn + BasisOut", both fields being detail record data from the table view.

    Am I missing a setting or control that's needed to allow this function?
  • Replied 4 August 2017, 3:02 pm EST


    What kind of data type do the BasisIn and BasisOut fields have? Please make sure that they have the compatible type for arithmetic operations.

    You can try to use other methods to get a calculated field and total it:

    1) Add extra data filed to SQL query of the report's data source, like this:

    SELECT Products.ProductName,
        [Order Details].UnitPrice,
        [Order Details].Quantity,
        [Order Details].UnitPrice * [Order Details].Quantity AS SubTotal

    After that you can use created SubTotal field in you report.

    2) Adds a new custom field to the report's fields collection in the DataInitialize and calculate it in the FetchData at run-time. Please take a look at the following sample:

    Private Sub ActiveReport_DataInitialize()
        Me.Fields.Add "ExtField"
    End Sub

    Private Sub ActiveReport_FetchData(EOF As Boolean)
        Me.Fields("ExtField").Value = Me.Fields("UnitPrice").Value * Me.Fields("Quantity").Value
    End Sub

    You can use created ExtField field in you report.

    I have attached a small sample that demonstrates these methods.

  • Replied 4 August 2017, 3:02 pm EST

    Thank you for the reply. I was using option 2 in your reply, which still does not work for some reason, but have abandoned. I have moved on to option 2 and all seems well so far, but will save investigation for a later time.

    Thank you again, especially for the example.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels