Formidable Pro makes it easy to perform calculations using values entered in your form. You may perform basic numeric calculations, separate value numeric calculations, or text calculations in a calculated fields form.

### Numeric calculations

If you would like to perform a calculation where the numeric value used in a calculation fields form can be seen by the user, follow the directions below.

- Go into edit your form.
- Add a
**Number**field to calculate the total. Set it to 'Read Only' if you would like users to see, but not edit, the total.

If you do not want users to see the total, set the Visibility to 'Administrator'. - In the Field Options for the total field, select
**Calculate the default value for this field**.

- Use the
**Select a value to insert into the box below**dropdown to add fields to your calculation. You can use the field ID or key synonymously in a calculation. Your calculation might look something like: [25]+[26]+[27] or ([25]*8)+([27]/2). In the example below, two Number fields are multiplied:

- Enter the number of
**decimal places**for your total. - The total will be updated each time a field that is used in your calculation is changed.

You can use the total field value in your success message, email, or View. If you would like your users to make a payment with this total, you can pass the total amount to Paypal or Stripe.

### Separate value calculations

Follow the directions below if you would like to perform a calculation where the value used in a calculation is not seen by the user. For example, if you have a radio button field with two options (Gold, Silver), then the text must be converted to numbers before calculating the total.

- Go into edit your form.
- Check
**Use separate values**for each field that will be used in your calculation (this can be found in the Field Options for Dropdown, Radio Button, and Checkbox fields).

- Add the number that will be used in your calculation to the end of each saved value. The calculation will only use numbers and decimals from the end of each saved value. Any other text or numbers before this will be ignored.

*Please note that the saved value***cannot**be identical to any other saved value. If you have saved values that must have the same numeric value, they need to be entered like this: Gold - $25.00, Silver - $25.00. - Add a
**Number**field to calculate the total. Set it to 'Read Only' if you would like users to see, but not edit, the total.

If you do not want users to see the total at all, set the Visibility to 'Administrator'. - In the Field Options for the total field, select
**Calculate the default value for this field**.

- Use the
**Select a value to insert into the box below**dropdown to add fields to your calculation. You can use the field ID or key synonymously in a calculation. Your calculation might look something like: [25]+[26]+[27] or ([25]*8)+([27]/2). In the example below, we are simply adding two fields together:

- Enter the number of
**decimal places**for your total. - The total will be updated each time a field that is used in your calculation is changed.

### Text calculations

If you would like to combine text from multiple fields into a single field in your form, you may use Formidable's text calculations. Follow the directions below to concatenate multiple field values into a text field.

- Go into edit your form.
- Add a
**Single Line Text**field to your form. This field will contain the combined text. - Go into the field options and scroll down to
**Dynamic Values**. Select 'Calculate the default value for this field ' and 'This calculation is copying text'.

- Use the
**Select a value to insert into the box below**dropdown to add fields to your calculation. Any spaces or characters used in this box will show in the final value.

- Save your form and preview it. The value will be updated each time a field that is used in your calculation is changed.

### Calculate a user's age

If you would like to calculate a user's age (in years) when they enter their date of birth, follow the instructions below.

- Add a
**Date**field to your form. This will be the 'Date of birth' field. - Add a
**Number**field to your form and title it 'Age'. This is the field where the age will be calculated.- If you want the user to see the age, select 'Read Only'.

If you do not want the user to see the 'Age' field, then set the field Visibility to 'Administrator'. - In the field options select
**Calculate the default value for this field**. Insert this calculation into the box:[age id=25]

Replace '25' with the ID or key of your 'Date of birth' field.

- If you want the user to see the age, select 'Read Only'.
- Now when the user inserts their birthday, the age will show up in the 'Age' field.

**Note**: Make sure nothing is entered in the "*decimal places*" area in Field Calculations when calculating an age.

If you would like to show the current age in a View, use the date field instead of a calculation so it will always be up to date. Follow the instructions on how to show an age in real time.

### Calculate number of days between two dates

If you would like to calculate the number of days between two dates, follow the instructions below.

- Add a
**Date**field to your form and title it 'Date 1'. Go to Field settings → Field Key and set the value to 'date1'. This will be your starting date field.

- Add another
**Date**field to your form and title it 'Date 2'. Go to Field settings → Field Key and set the value to 'date2'. This will be your end date field.

- Add a
**Number**field to your form and title it 'Number of Days'. This is the field where the number of days will be calculated.- If you want the user to see the 'Number of Days' field, select
**Read Only**.

If you do not want the user to see the 'Number of Days' field, set the field**Visibility**to 'Administrator' in your field settings.

- In the Field options, select
**Calculate the default value for this field**. Insert this calculation into the box:[date2]-[date1]

Or you could select the field ID or key from the dropdown,

**Select a value to insert into the box below**.

- If you want the user to see the 'Number of Days' field, select
- As a result, when the user selects their chosen dates, the number of days between those two dates will be displayed in the 'Number of Days' field.

### Get the total of the values of a Repeater

If you are using calculations in a repeater, follow the instructions on how to get the total of the values in a field in a repeater.

### Unique field combination

Do you need the combination of two fields to be unique? There is a custom code route, but it's possible you may be able to do this without custom code.

- Add a hidden field to your form.
- Check the 'Unique' box and customize the unique error message for this field.
- Check the box to 'Calculate the default value for this field' and the 'this calculation is copying text' box.
- Insert a calculation that includes the two fields. So if you are limiting the form to one user per date, include the user ID and date fields in the calculation. It would work the best to include a dash between the two field values like [25]-[26].
- This will work best if both of the fields used in the calculation are required. Now when a logged in user tries to select and submit a date they already submitted, your unique message for the hidden field will be displayed.

#### Number Format

- If you would like to round your total to two decimal places, enter
**2**in the 'decimal places' box. - If you would like to round your total to the nearest whole number, enter
**0**in the 'decimal places' box. - If you would like to add two decimal places in a single field by default, enter
**2**in the 'decimal places' box and**[x]**in the calculations box (where**x**is the field ID/key). - If you would like to round a number down to its nearest integer, add
**Math.floor**to the beginning of your calculation.Math.floor([25]+[26]+[27])

- If you would like to add a dollar sign in front of your number, go into your form and click on 'Settings' → 'Customize HTML'. Find the box that corresponds to the field holding the number. Put a dollar sign in front of [input].

If the dollar sign appears above the field, you need to decrease the field size.

### Advanced numeric calculations

- If you would like to add exponents to an equation, you can use
**Math.pow**:Math.pow([x],2)

Replace x with a field ID for the base and replace 2 with the exponent amount.

- For more advanced calculations, such as minimums, maximums, and square roots, see the JavaScript Math object.

### Calculation demo

Click here to see a calculations demo.