Perform Calculations | Formula Field - Zoho Forms

Formula

Overview

Make your form a math wiz by allowing it to perform calculations. You can total up costs, process grade quizzes, apply discounts, and more! 

Use the  Formula  field to set up any form calculation. When your respondents fill in the form, calculations will be performed based on their input. The answer will be displayed in the field you have entered your formula in.

Using the Formula field you can,

  • Perform mathematical operations such as addition, subtraction, multiplication, and division 
  • Use certain  math functions  to calculate differences between two times, dates, and more 
  • Set up conditional calculations  to perform calculations based on the respondent's answers  

Setup

To add a formula field to your form,

  1. Click the Formula field under the Number section.
  2. In the pop-up, your form fields would appear in the left pane. Use the fields on the left, numbers, and mathematical operators on the right to come up with your formula.
    Formula field setup
  3. Click Done.
  4. You can choose to hide this field from your respondents using the   Hide Field  option under Properties
  5. If you wish to edit your formula, click the  Edit  link under Properties .
Supported Field Types for Formula
Number, Decimal, Currency, Slider, Rating, Formula, Radio, Checkbox, Multiple Choice, Dropdown, Image Choice, Date, Date-Time, Time.

For example, you can calculate the amount your customer has to pay using the formula field and display the amount in the payment field automatically. For this, you can set the formula as  Item * Quantity , where the number  value assigned  for the field  Item  is taken for the calculation.
Notes
Note
While using the Formula field as a variable for calculating another formula, ensure that the two formulas are not mutually dependent. If you have come across an error because two formulas are mutually dependent, then refer to the below example:
If  n1, n2, n3 are three number fields, and f1, f2, f3 are the formulas that you have created where,

f1= n1+ n2 
f2= n3 + f3
f3= f1 + f2

Formula 2 depends on Formula 3's answer (and vice versa) to perform calculations, resulting in an endless loop. Recheck your formula to avoid this type of infinite loop.

Functions

Using the math functions we support, you can calculate the differences between time and date fields, and also round off decimal numbers into integers. You will find  Functions  in the right pane of the  Formula  field pop-up. 

To use a function,

  1. Tap on the math function you wish to add.
  2. It generates a syntax like this:  Function (Field Name - Field Name) .
  3. Replace the field's placeholders with the required form fields by clicking them from the left pane. 
    Using functions in Formula field

Supported Math Functions


Function
Role
Supported Field Types
DayDiff
Returns the day difference between two date values
Date, Date-Time
MonthDiff
Returns the month difference between two date values
Date, Date-Time
YearDiff
Returns the year difference between two date values
Date, Date-Time
HourDiff
Returns the hour difference between two time values
Time, Date-Time
MinutesDiff
Returns the minute difference between two time values
Time, Date-Time
RoundUp
Rounds off the decimal number to that next value, away from zero
Decimal, Currency, Formula
RoundDown
Rounds off the decimal number to that of the previous value
Decimal, Currency, Formula
Round
Rounds off a decimal number to that of the next number when the decimal
value is .5 or above, and to the previous number when the decimal value is below .5
Decimal, Currency, Formula
Learn more about other functions and their usage. 

Adding a Unit to Formula

You can add a unit to your formula to show the result more contextually in the live form. A unit can be added once the formula configuration is completed. 

To include a unit for the formula calculated value:

  1. Enter a suitable Unit under Properties .

    Unit
  2. You can select to position this unit either as a Prefix or a Suffix.
    Prefix and Suffix

    Notes
    Note : The unit for a formula will be displayed only in Subform's Pop-up mode.
Know more about performing calculations.