Formula fields

Formula fields

Zoho People now supports formula fields. This post illustrates it.

Formula fields are fields whose value is calculated instead of being entered by the user. Using this, number, decimal and date manipulations can be done. The value of this field could be numeric or date depending on the output of the formula. In date manipulations, the result will be given in milliseconds, which you can format as per you need. The operators we support are +, - , *, /. Formula fields get recalculated automatically whenever the formula is changed. It also gets recalculated, when a field involved in the formula is changed.

To add formula fields

i)   Go to Customize form.

ii)  Double click or drag formula field from the tool box.

iii) The fields which can be used for calculation are listed at the right side of the formula field popup.

To construct the formula

To select a field or operator for formula construction

i)                     Click at the position in the Specify formula text area where you need to insert the operator or field.

ii)                   Then click on the corresponding operator.

To enclose part of formula within brackets, select that part and then click on the brackets.

To insert current date or timestamp click on the icons (shown in red in the below picture) present near the operators

Sample formula expressions

1.  Formula to calculate leave duration

   ( ToDate – FromDate ) / (1000 * 60 * 60 * 24)

2.  Formula for PF calculation

   ( BasicPay  *  12 ) / 100

For example, let us add a formula field named Net Pay in the Payslip form to calculate the net pay.



To edit the formula field

Use the edit option present at left side of the field in the customize form page. The following figure illustrates this.



Since the user need not enter the value for formula fields, they are not rendered while adding a record. However, formula fields are rendered with the calculated value when the records are viewed. Below picture illustrates this


Error messages

While configuring formulas you can receive error messages like

i)                    Field name 'fdfdfff' does not exist in the form - Arises when you try to specify a field for formula construction which is not there in the listing.

ii)                   Found an error in the formula. Cannot add two date expressions - When you try to add two date fields.