Use the frmmath shortcode to calculate the value of a math expression. Place the math expression inside the frmmath shortcode and the result of the calculation will be displayed. For example, this will display the result of subtracting one stat from another:
[frmmath] [frmstats id=67 type=total]  [frmstats id=42 type=total] [/frmmath]
This shortcode is used with static values and values that have already been saved in a form. If you are looking for calculations that change while the form is filled out, see form field calculations.
Values
The math expression can contain numbers and other shortcodes (like the frmstats shortcode). In a View, email, or success message, field shortcodes like [100] can also be included.
Operators
A math expression can use addition (+), subtraction (), multiplication (*), mod (%), and division (/). Parentheses can also be included. They can be nested, e.g.
[frmmath] (1 + (3 * 3)) / 2 [/frmmath] Result: 5
Where can the math functions be used?
The frmmath shortcode can be used in a View, directly on a page, in an email, as a default value, or anywhere else that WordPress shortcodes are processed.
Parameters
 error  the content to display if there's an error in the math expression.
 error=debug  The math expression will be displayed, as it appears after shortcodes inside it are processed. You can use this to help determine why the error occurred. Only use error=debug during development and testing, not when the content is live.
 error="content of your choosing"  The value set for the error parameter will be displayed. Suggested values: a default number (e.g. 0), a message, or nothing. The default is to display nothing.
Read more about math errors.
 clean  Determines whether the math expression should be cleaned of nonmath characters.
 clean=1  All content that doesn't belong in a math formula, like text, punctuation marks, and currency symbols, is removed. This removal happens after shortcodes have been processed, just before the math expression is evaluated.
 clean=0  The math expression remains as it is after shortcodes have been processed. This is the default.
 thousands_sep  character used to separate thousands. Example: thousands_sep='.'
 decimal  number of decimal places to round. Example: decimal=2
 dec_point  character used for decimal point. Example: dec_point='.'
Using math in a conditional
If you'd like to display content conditionally based on the result of a frmmath calculation, you can use the following approaches.
Use math directly in a conditional
If you want to display the content in a View and your math expression has only field shortcodes (e.g. [100]) and set numbers (e.g. 10), you can use the frmmath shortcode directly with the frmcondition shortcode. Include source=frmmath and put the math expression in the content param. For example, to multiply two field values, use the following approach:
[frmcondition source=frmmath content="[100] * [102]" greater_than=10]content if the result is greater than 10[/frmcondition]
Save the math value in a param
For math expressions that use standard WordPress shortcodes, like frmstats and frmfieldvalue, you can use frmsetget to save the result of frmmath in a param. Then you can use the param with frmcondition.
For example, an event has space for 100 people. The stat for the number of spaces already taken is: [frmstats id=18 type=count].
You can calculate the remaining spaces for the event and save the value in a parameter:
[frmsetget param=remaining_spaces] [frmmath] 100  [frmstats id=18 type=count] [/frmmath] [/frmsetget]
You can then show content conditionally based on the number of remaining spaces.
[frmcondition source=param param=remaining_spaces greater_than=0 less_than=10] If you want to attend, sign up now! There are fewer than ten spaces remaining.[/frmcondition]
[frmcondition source=param param=remaining_spaces less_than_or_equal_to=0]Sorry! We're fully booked this year. We hope you can join us next year.[/frmcondition]
Errors
If the content inside the frmmath shortcode isn't a proper math expression, the value in the error param will be displayed.
Any of the following in the math expression will cause an error:
 letters, punctuation (other than commas and periods), or other nonmath characters, like $
 unmatched parens
 missing or empty values, e.g. 3 + * 2
Note: Empty content isn't considered an error.
How the math is evaluated
The math expression is evaluated following a standard PEMDAS style approach:

 parentheses are evaluated first,
 then multiplication, mod, and division (left to right),
 then addition and subtraction (left to right).
You can read more about this approach at https://www.mathsisfun.com/operationorderpemdas.html
Examples
Average test score
In a View, show the average test score of each student by adding the scores from three different forms and dividing by three. The student id in the form used for the view is in field 42. Fields 100, 150, and 165 hold the student test scores. Fields 101, 151, and 165 hold the student ids. Each of the three forms limits entries to one per user.
[frmmath] ([frmstats id=100 101=[42] type=total] + [frmstats id=150 151=[42] type=total] + [frmstats id=160 165=[42] type=total])/3 [/frmmath]
Stat with filters combined with OR
The stats shortcode can give you the number of gold members and, separately, the number of bronze members. If you want the total number of members who have either the gold or bronze level, you can use the math shortcode to combine the two stats. Field 25 holds the membership level.
[frmmath] [frmstats id=25 25="bronze" type=count] + [frmstats id=25 25="gold" type=count] [/frmmath]
Show content if a user filled out one of two forms
Show content if a user has filled out at least one of two forms. Field 70 is a field in Form A, and field 80 is a field in Form B.
First, use math to determine how many times the user has filled out both forms and save the result in a param.
[frmsetget param="forms_total"] [frmmath] [frmstats id=70 user_id=current type=count] + [frmstats id=80 user_id=current type=count] [/frmmath] [/frmsetget]
Then use the result in a conditional.
[frmcondition source=param param=forms_total greater_than=0] content you want to display [/frmcondition]
Show incremental content
In the content box in a view, you may show incremental content. This example will show the content on every 3rd entry show in the view. This count resets each time the page is changed.
[frmcondition source=frmmath content="[entry_position] % 3" equals="0"]This is the incremental content[/frmcondition]
Add values from Views which may have no entries
You may want to combine the values of several Views, each of which displays one number, which may also display the no entries message. Since frmmath requires a properly formatted math expression, it wouldn't work properly with a View that displays the no entries message. To get around this, you can use frmcondition to only display Views when they have values.
 Begin your math expression with a value. It could be a field value, a fixed value (like 100), or a shortcode that results in a value. If you don't have anything like that naturally, you would use 0.
 In each View, put "none" in the no entries message box.
 For each View you want to add, create a conditional to test if the value of the View is not like "none". Put + and the View shortcode inside frmcondition.
[frmcondition source=displayfrmdata id=42 not_like="none"] + [displayfrmdata id=42 filter=limited][/frmcondition]
 The full math expression for adding two Views could look something like this:
[frmmath] 0 [frmcondition source=displayfrmdata id=42 not_like="none"] + [displayfrmdata id=42 filter=limited][/frmcondition][frmcondition source=displayfrmdata id=36 not_like="none"] + [displayfrmdata id=36 filter=limited][/frmcondition][/frmmath]
Add values submitted in Lookup checkbox fields
If you have set up multiselect cascading fields using Lookup checkboxes, you may want to calculate the total of the values submitted and pass the total to a payment form. To get started, you can use the following approach:
 Create a Single Entry View.
 Add a filter in the Advanced Settings of your View that says 'Entry key is equal to [get param=pass_entry].'
 In the Content box, add the following math shortcode.
[frmmath][100 sep=" + "][/frmmath]
 Save the View then publish it on a page. Copy the URL of the page.
 Go to the form that users will be filling out. Click on the Settings tab.
 Under On Submit, select 'Redirect to URL'. In the box that appears, paste the URL of the page where your View is published, followed by ?pass_entry=[key]. Note: Leave the word [key] as it is.
 In your Payment form, look for the field where you want to store the payment amount, then add the View shortcode you created in Step 4. Don't include 'filter=limited' to the View shortcode.
 Click Update to save your form.
Show number as currency in a View
In the Content box in a View, you may show the number as currency. The easiest way to format a value as currency, is to use [100 format=currency].
If you need more customization, the frmmath shortcode will help. This example will add a currency symbol and include up to two decimal places in the displayed number. Your shortcode should look something like this:
$ [frmmath decimal=2] [100] [/frmmath]
Where 100 is the number field ID. Replace $ with your preferred currency symbol.
Show separate value as currency in a View
If you are adding prices in your Saved Value, you may want to display the number as a currency. To get started, you can use the following approach:
 Enable separate values for your checkbox, radio button, or dropdown field.
 For each Saved Value, set the text to something like "black shirt 20". Don't use any punctuation, parentheses, dashes, asterisks, slashes, plus signs, percentage signs, or any symbol that could be used in a math expression.
 Create a View. In the Content box, you may use this shortcode that will add a currency symbol and include up to two decimal places in the displayed number. Your shortcode should look something like this:
$ [frmmath clean=1 decimal=2] [100 show=value] [/frmmath]
 Where clean=1 param will remove all nonmath characters, including the letters.
 Replace 100 is the checkbox, radio button, or dropdown field ID using separate values.
 Replace $ with your preferred currency symbol.
Show separate incremental counts for each user
If your users submit a single form multiple times, you may want to assign an incremental number counter to the form every time a loggedin user fills it in. To get started, you can use the following approach:
 Enable frontediting of entries for loggedin users.
 Add a hidden field to your form with this shortcode as a default value.
[frmmath] [frmcondition source=frmfieldvalue field_id=631] [frmfieldvalue field_id=631 user_id=current] + [/frmcondition] 1 [/frmmath]
Replace 631 for the id of the same field, the field that has this frmmath shortcode in it.
 It will grab the latest count from the loggedin user in the form (if there is one) and add one to it. By default, it will start with 1.
Note: A limitation with this is that if a user opens up the same form more than once at the same time, they will all get the same number. To avoid this, you could use custom code with the frm_validate_field_entry hook.
Credits
The clever idea of creating a math shortcode came from Andrew Klimek. The code he kindly shared was the inspiration for the frmmath shortcode. Many thanks, Andrew!