calculatedcolumns

 
          $calculated_columns Predefined Array  
Calculated columns are virtual columns that are not physically stored in your database table Instead, their values are calculated from one or more other columns. In each generated report by Smart Report Engine, you should find a configuration file named “calculated_columns.php”. This file is for configuring any number of calculated columns needed for any report generated by Smart Report Engine. You can find this file at:
/{Smart-Report-Engine-PATH}/SRM8/SRM/Reports8/rep{report-name}/calculated_columns.php
where: {Smart-Report-Engine-PATH}: The path in which you uploaded Smart Report Engine on your local or remote server.
{report-name}: Your generated report's name.
Inside the "calculated_columns.php" configuration file, you should find the "$calculated_columns" predefined array. In this array, you can define each calculated column you want to add to your report along with the method to calculate it as shown in the code example below.
In the following code snippet, we define one calculated column “total_price” and linked it to the function that should be used to calculate its value. Please note that the value of any calculated column is calculated by the function linked to it and which should accept only one parameter “$row” which represents any row in the report. Therefore if we need to include any column in the calculation formula we should refer to that column as $row[“name_of_the_column”] For example, $row[“unit_price”]. Once we save the calculated_column.php file changes and refresh the browser we should be able to see the calculated columns displayed in the report.
# This method is exclusive to the commercial edition and is not supported in the community edition .

# Code Example

 
           $calculated_columns = array(    
  "total_price"=>function($row){

       return $row["unitprice"] * $row["quantity"];
      }    
);