Simple Calculation

I have a simple report which brings through some sales prices and totals from a SQL database. This all works fine but I want to calculate the ex VAT price in the report
The current Text field is [Report_printInvoices.SalePrice] and this shows for each data line.
Now I want this value divided by 1.2 but just get an error or the value and then / 1.2 as text
I assume I am missing something really simple but can't see it. - I was expecting to just type [Report_printInvoices.SalePrice] / 1.2

Comments

  • edited 1:57AM
    Hello,

    You forgot to enclose whole expression in the brackets:
    [[Report_printInvoices.SalePrice] / 1.2]
  • edited 1:57AM
    I'm having similar issue try to write the similar expression but give me the error
    [
    [qryCompletedVisits.Jan]/[[qryTotalVisitsAssigned.Jan]-[qryCancelledVisits_testing.Jan]]
    ]
    
    Also tried like this 
    [[qryCompletedVisits.Jan]/[[qryTotalVisitsAssigned.Jan]-[qryCancelledVisits_testing.Jan]]]
    

    Error
    wrote:
    Cell123: Error BC30023: Bracketed identifier is missing closing ']'
    Function: Error 40005: function 'ToString' shadows an overrideable method in the base class 'Object'. To override the base method must be declare 'override....'
    Thanks for your help in advance
  • edited January 2018
    Farhan wrote: »
    I'm having similar issue try to write the similar expression but give me the error
    [
    [qryCompletedVisits.Jan]/[[qryTotalVisitsAssigned.Jan]-[qryCancelledVisits_testing.Jan]]
    ]
    
    Also tried like this 
    [[qryCompletedVisits.Jan]/[[qryTotalVisitsAssigned.Jan]-[qryCancelledVisits_testing.Jan]]]
    

    Error Thanks for your help in advance

    Resolved after playing with that use curly brackets
    [[qryCompletedVisits.Jan]/([qryTotalVisitsAssigned.Jan]-[qryCancelledVisits_testing.Jan])]
    

    after use the above calculation as aim to see the %Achieve simply change the format of the field to to % with two decimal points and display as expected
    Thanks
    Thanks
  • edited 1:57AM
    for complex calculation, use script as custom function
    namespace FastReport
    {
      public class ReportScript
      {
        public double CustomFunction(double a, double b, double c)
        {                 
            return a / (b - c);
        }
      }
    }
    

    in your textobject:
    [CustomFunction([qryCompletedVisits.Jan],[qryTotalVisitsAssigned.Jan],[qryCancelledVisits_testing.Jan])]
    

Leave a Comment