The Formula Fields step Step allows you to add create calculated fields that are populated at run time. These calculated fields are generally based on existing fields . In the below figure, interest amount is calculated applying a formula on the fields of the selected data source.
...
Figure 13: Formula Fields Step
Action Button | Comments |
Add | To add a new formula field |
Delete | To delete the selected formula field |
For each added formula field, following properties are set:
Formula String Syntax
...
Property
...
Values
...
Comments
...
Name
...
Enter
...
in the data source. These calculated fields are populated at runtime and can be used to perform complex calculations such as interest amounts or totals.
Action Buttons
Action | Description |
---|---|
Add | Add a new formula field to the Query Object. |
Delete | Delete the selected formula field. |
Formula Field Properties
When adding a formula field, you can configure the following properties:
Property | Description |
---|---|
Name | Name of the formula field as visible to the end user. |
Return Type |
Number
Char
Date
Length ofSpecifies the data type of the formula field. Options include Number, Char, or Date. |
Precision |
Enter
Defines the length of the field for Char data type |
or the precision for Number data type. |
Scale |
Enter
Specifies the number of digits after the decimal point for Number data type. |
Formula |
Formula String
Java script syntax formula
...
The formula string, written using JavaScript syntax. You can use field names |
...
, define variables |
...
Example:
For a formula field named TotalAmount,
var total ;
if (unitprice < 10 )
{total = unitprice*quantity;}
else
{total = unitprice;}
...
, and use logical operators. |
Formula String Syntax
Formulas in Kyvos Reporting are created using JavaScript syntax. You can create formulas with conditional logic and variables, and use logical operators for more complex calculations. Each statement in the formula must be separated by a semicolon (;
).
Example:
To calculate the total amount based on unit price and quantity, you can create a formula as follows:
Code Block |
---|
var total;
if (unitprice < 10) {
total = unitprice * quantity;
} else {
total = unitprice;
}
TotalAmount = total; |
This formula checks if the unit price is less than 10. If so, it calculates the total as unit price multiplied by quantity; otherwise, it just uses the unit price as the total.