Best Practice for Calculations

Let us consider calculating profit as example

Profit := Income-Expenditure;

There is no guarantee that Income and Expenditure data will always have a numeric data type. Some users may prefer to use ‘No Income’ or ‘No Expenditure’ values

The best way to avoid problems with data quality is to follow the pattern below.

  • Create variables for every input parameter.
  • Assign input parameters to variables inside try expect block
  • Perform calculations
  • Return value

Example:

Var
vIncome: Float;
vExpenditure: Float;

begin
// Converting strings to Floats
Try
vIncome:=Income;
except
vIncome:=0;
end;

try
vExpenditure:=Expenditure;
except
vExpenditure:=0;
end;

// Calculation

Result := vIncome-vExpenditure;
end;

For more technologies supported by our ETL Software see Advanced ETL Processor Versions

Confused? Ask question on our ETL Forum
Last updated: September 17, 2022