This page is part of the Calculated Fields Form's documentation. The Calculated Fields Form is plugin for WordPress with free and commercial versions.

Mathematical Module

a) The module includes the basic mathematical operators:

fieldname1+fieldname2

fieldname1*fieldname2

fieldname1/fieldname2

fieldname1-fieldname2

or mathematical equations with multiple fields and fields grouping included.

fieldname1*(fieldname2+fieldname3)

b) The module includes more specific operations, some of them available as buttons in the plugin's interface, the other operations should be typed manually in the equation's editor:

Operation Description Demo
abs(x) Returns the absolute value of x

If the value of fieldname1 is -7.25, the result of: abs(fieldname1) would be 7.25

acos(x) Returns the arccosine of x, in radians

If the value of fieldname1 is 0.5, the result of: acos(fieldname1) would be 1.0471975511965979

asin(x) Returns the arcsine of x, in radians If the value of fieldname1 is 0.5, the result of: asin(fieldname1) would be 0.5235987755982989
atan(x) Returns the arctangent of x as a numeric value between -PI/2 and PI/2 radians If the value of fieldname1 is 2, the result of: atan(fieldname1) would be 1.1071487177940904
atan2(x,y) Returns the arctangent of the quotient of its arguments If the value of fieldname1 is 8 and fieldname2 is 4, the result of: atan2(fieldname1,fieldname2) would be 1.1071487177940904
ceil(x) Returns x, rounded upwards to the nearest integer If the value of fieldname1 is 1.4, the result of: ceil(fieldname1) would be 2
cos(x) Returns the cosine of x (x is in radians) If the value of fieldname1 is 3, the result of: cos(fieldname1) would be -0.9899924966004454
exp(x) Returns the value of E^x If the value of fieldname1 is 1, the result of: exp(fieldname1) would be 2.718281828459045
floor(x) Returns x, rounded downwards to the nearest integer If the value of fieldname1 is 1.6, the result of: floor(fieldname1) would be 1
log(x) Returns the natural logarithm (base E) of x If the value of fieldname1 is 2, the result of: log(fieldname1) would be 0.6931471805599453
max(x,y,z,...,n) Returns the number with the highest value If the value of fieldname1 is 5 and fieldname2 is 10, the result of: max(fieldname1, fieldname2) would be 10
min(x,y,z,...,n) Returns the number with the lowest value If the value of fieldname1 is 5 and fieldname2 is 10, the result of: min(fieldname1, fieldname2) would be 5
pow(x,y) Returns the value of x to the power of y If the value of fieldname1 is 4 and fieldname2 is 3, the result of: pow(fieldname1, fieldname2) would be 64
random() Returns a random number between 0 and 1  
round(x) Rounds x to the nearest integer If the value of fieldname1 is 2.5, the result of: round(fieldname1) would be 3
sin(x) Returns the sine of x (x is in radians) If the value of fieldname1 is 3, the result of: sin(fieldname1) would be 0.1411200080598672
sqrt(x) Returns the square root of x If the value of fieldname1 is 9, the result of: sqrt(fieldname1) would be 3
tan(x) Returns the tangent of an angle If the value of fieldname1 is 90, the result of: tan(fieldname1) would be -1.995200412208242

Pay special attention to the next two operations. The first of them, very extended its use in equations for calculations the cost of products and services, and the other one to obtain a date.

Operation Description Demo
prec(x,y) Return the x number with y decimal digits

If the value of fieldname1 is 10.33323, the result of: prec(fieldname1,2) would be 10.33

If the value of fieldname1 is 10.3365, the result of: prec(fieldname1,2) would be 10.34

If the value of fieldname1 is 10, the result of: prec(fieldname1,2) would be 10.00

cdate(x, format) Returns the number x formatted like a Date, the second parameter defines the format of the output date ('mm/dd/yyyy', 'dd/mm/yyyy'). The number represents the number of days from Jan 1, 1970

If fieldname1 is a date field, and its value is 3/11/2013: cdate(fieldname1+10) would be 13/11/2013

Sample valid equations:

To calculate the monthly payment in a lease calculator:

The fields implied are:

Load amount: fieldname1

Residual value: fieldname2

Interest rate %: fieldname3

Number of months: fieldname4

The corresponding equation for monthly payment is:

prec((fieldname1*fieldname3/1200*pow(1+fieldname3/1200,fieldname4)-fieldname2*fieldname3/1200)/(pow(1+fieldname3/1200,fieldname8)-1),2)

Logical Module

The logical module include the following functions:

Function Description Demo
IF(condition, value if true, value if false) Checks whether a condition is met, and returns one value if true, and another if false.IF(logical_test, value_if_true, value_if_false)

If the value of fieldname1 is 10 and the value of fieldname2 is 20, the result of:

IF(fieldname1 < fieldname2, fieldname1, fieldname2)
would be 10

AND(x,y,z,....) Checks whether all arguments are true, and return true if all values are true, and false in another way. AND(logical1,logical2,...)

Suppose there are three fields, fieldname1, fieldname2 and fieldname3, with values: 10, 20 and 30 respectively, so:

AND( fieldname1<100, fieldname2<100, fieldname3<100)
would be true

but

AND( fieldname1<100, fieldname2<100, fieldname3<25)
is false, because the fieldname3 is bigger than 25

OR(x,y,z,....) Checks whether any of arguments is true, and return true if any of values is true, and false if all values are false. OR(logical1,logical2,...)

Suppose there are three fields, fieldname1, fieldname2 and fieldname3, with values: 10, 20 and 30 respectively, so:

OR( fieldname1<100, fieldname2<100, fieldname3<25)
is true, because at least the two initial conditions are true, inclusive if the third condition fails.

but

OR( fieldname1<5, fieldname2<5, fieldname3<25)
is false, because the three conditions fail

NOT(x) Changes false to true, or true to false.NOT(logical)

NOT(true)
return false

NOT(false)
return true

IN(x,[x,y,z,....]) Checks whether the term is included in the second argument, the second argument may be a string or strings array. IN(term, string/array)

IN(10,[10,20,30,40])
Return true

IN('world', 'hello world')
Return true