This plugin is part of Gravity Perks, a suite of 39+ essential Gravity Forms addons with support you can count on.
What does it do?
Advanced Calculations completely revamps calculations in Gravity Forms. Not only does it empower you with advanced mathematical functions and conditionals, it improves the formula editing experience with a powerful new editor, complete with syntax highlighting, autocompletion, shorthand field references, and so much more!
With Advanced Calculations you can create:
- Mortgage calculators
- Advanced calculated products
- Auto loan calculators
- Investment/Retirement calculators
- BMI calculators
- And many more!
Features
- Heaps of mathematical functions.
Spreadsheet style math directly in your form. - Conditional statements.
Specify multiple formulas in the same field; use the right one based on your conditions. - Formula shorthand.
Simplify your formulas with our field reference shorthand. No more cumbersome merge tags! - Syntax highlighting.
Clarify your complex formulas and spot issues quickly with automatic syntax highlighting. - Secure, tamperproof calculations.
All calculations are recalculated on submission for accuracy and security. - Seamless integration.
Automatically enhances all calculation-enabled fields like Number and Calculated Product fields. - Automatic updates.
Get updates and the latest features right in your dashboard. - Legendary support.
We’re here to help! And we mean it.
Documentation
How do I enable this functionality?
After installing and activating Gravity Forms Advanced Calculations,
Add a Number field to your form. | |
Check Enable Calculation. | |
Insert advanced calculations into form. Use the Formula Cheatsheet for a primer on calculations. |
Feature Details
Merge Tag Shorthand
The true power of calculations with Gravity Forms comes from being able to reference other fields to create calculations from what users have entered. Gravity Forms uses merge tags to reference fields. Merge tags are referenced using the field ID, with or without the descriptor, such as {Field A:1}
or {:1}
.
Gravity Forms Advanced Calculations adds shorthand for fields to clean up your calculations and make it easier to keep track of everything. The shorthand for the same field shown above is written as F1
.
Shorthand offers more readable calculations, especially for complicated functions.
Conditional Statements
Advanced Calculations supports conditional statements such as if/else and if/elseif/else. Use these statements to evaluate calculations based on field values.
if/else
if( F1 < 5.5 ):
F1 * 50
else:
0
endif;
if/elseif/else
if( F1 < 5.5 ):
F1 * 50
elseif( F1 >= 10 ):
F1 * 25
else:
0
endif;
elseif
statements as needed. You are not limited to one.The following comparison operators are supported:
==
Equal to!=
Not equal to>
Greater than<
Less than>=
Greater than or equal to<=
Less than or equal to
Syntax Highlighting
Advanced Calculations adds syntax highlighting and autocompletion to the calculation text area. Syntax highlighting drastically improves the readability of calculations, especially complicated ones that use conditional statements and functions.
Autocompletion aids you when inputting a function or conditional statement. When you start typing any supported function, the editor will suggest a completion. Click the suggested function (or hit return) to insert the full function with placeholder values.
The editor also automatically closes parentheses and merge tag braces. Say goodbye to invalid formulas because of an errant parenthesis!
Tooltips
When hovering over shorthand field variables and merge tag field variables with no descriptor in the formula editor, you will see a tooltip displaying the field’s label.
Functions
Advanced Calculations adds support for common functions to both save you time and effort and provide more accurate results.
Absolute Value – abs
Returns the absolute value of a number.
Sample Usage
abs( -78 )
abs( F1 )
Syntax
abs( value )
value
– The value or field of which to return the absolute value.
Example
In the below example, the retuned value is 14
.
abs( -14 )
Average – average
Returns the average value of the arguments given.
Sample Usage
average( F1, F2, 26 )
average( 1, 2, 3, 4, F1 )
Syntax
average( value1, [value2, ...] )
value1
– The first value or field to evaluate when calculating the average value.value2, ...
(optional) – Additional values or fields to evaluate when calculating the average value.
Example
In the below example, the returned value is 35
.
average( 12, 58, 35 )
Ceiling – ceil
Rounds a number up to the next largest integer.
Sample Usage
ceil( 25.4 )
ceil( F1 )
Syntax
ceil( value )
value
– The value to round up to the nearest integer.
Example
In the below example, the retuned value is 36
.
ceil( 35.8 )
Exponential – exp
Returns e^x, where e is Euler’s number (~2.718) and x is the provided value.
Sample Usage
exp( 25.4 )
exp( F1 )
Syntax
exp( value )
value
– The exponent to raise e to.
Example
In the below example, the retuned value is 148.4131591025766
.
exp( 5 )
Floor – floor
Rounds a number down to the nearest integer.
Sample Usage
floor( 75.763 )
floor( F3 )
Syntax
floor( value )
value
– The value to round down to the nearest integer.
Example
In the below example, the retuned value is 323
.
floor( 323.78 )
Future Value – fv
fv
calculates the future value of an investment based on constant-amount periodic payments and a constant interest rate.
Sample Usage
fv( F1, F2/12, F3, 10000, 1 )
fv( 0.05, 10, F1, F2 )
Syntax
fv( rate, numberOfPeriods, paymentAmount, presentValue, [endOrBeginning] )
rate
– The annualized rate of interest.numberOfPeriods
– The number of payments to be made.paymentAmount
– The amount per period to be paid.presentValue
– The current value of the investment.[endOrBeginning]
– (optional – 0 by default) – Whether payments are due at the end (0) or beginning (1) of each period.
rate
, number_of_periods
, and payment_amount
. For example, on a 60 month car loan this is paid monthly, the rate
should be divided by 12 and the numberOfPeriods
is 60. If the same loan was instead paid quarterly, the rate
should be divided by 4 and the numberOfPeriods
is 20.Example
In the below example, the retuned value is 0.023
.
fv( 0.0311, 60, 450, -25000, 0 )
fv
calculates a loan. To use it to calculate a growing investment, add a minus before the formula. For example:
-( fv( 0.08, 5, 300, 2500 ) )
Natural Logarithm – ln
ln
returns the logarithm of a number, base e. e is Euler’s number (~2.718).
Sample Usage
ln( 23 )
ln( F4 )
Syntax
ln( value )
value
– The value to calculate the logarithm, base e.value
must be positive.
Example
In the below example, the retuned value is 6.19644412779452
.
ln( 491 )
Logarithm – log
log
returns the logarithm of a number, base 10.
Sample Usage
log( 7 )
log( F2 )
Syntax
log( value )
value
– The value to calculate the logarithm, base 10.value
must be positive.
Example
In the below example, the retuned value is 1.6901960800285136
.
log( 49 )
Maximum – max
max
returns the largest value in the list of arguments.
Sample Usage
max( F1, F4, 67 )
max( 108, F7 )
Syntax
max( value1, [value2, ...] )
value
– The first value or field to evaluate when calculating the maximum value.[value2, ...]
– (optional) – Additional values or fields to evaluate when calculating the maximum value.
Example
In the below example, the retuned value is 49
.
max( 36, 49 )
Minimum – min
min
returns the smallest value in the list of arguments.
Sample Usage
min( F3, 56, F8 )
min( 3, F1 )
Syntax
min( value1, [value2, ...] )
value
– The first value or field to evaluate when calculating the minimum value.[value2, ...]
– (optional) – Additional values or fields to evaluate when calculating the minimum value.
Example
In the below example, the retuned value is 6
.
min( 18, 6 )
Round – round
round
rounds a number to the nearest integer.
Sample Usage
round( 12.7 )
round( F2 )
Syntax
round( value )
value
– The value to round to the nearest integer.
Example
In the below example, the retuned value is 9
.
round( 8.68 )
Square Root – sqrt
sqrt
returns the square root of a number.
Sample Usage
sqrt( F12 )
sqrt( 72 )
Syntax
sqrt( value )
value
– The number to calculate the square root.
Example
In the below example, the retuned value is 12
.
sqrt( 144 )
Hooks
No posts found.