Math filters: targeting a specific field value with [gravitymath]
The filter parameter of the [gravitymath] shortcode limits a calculation to the entries where a field has a given value. It works with scope="view", scope="form", and scope="visible". The [gravitymath] shortcode covers the other parameters.
Example: adding up two fields for the entries marked Yes #
This form has a Calculate drop down (field 1) and two Number fields, Number 1 (field 2) and Number 2 (field 3):

To add up Number 1 and Number 2 for the entries where Calculate is Yes, use this shortcode. Replace the View ID (8) and the View secret (abc123) with your View’s ID and secret:
Total: [gravitymath scope="view" secret="abc123" id="8" filter="filter_1=Yes&op_1=is"]{Number 1:2}+{Number 2:3}[/gravitymath]The total in the View counts only the two rows marked Yes:

Parts of the filter value #
The filter value is built from these parts, joined with &:
filter_N: The value to match, where N is the ID of the field or meta key.op_N: Howfilter_Nis compared:is(the default),isnot,contains,notcontains,gt(greater than), orlt(less than).limit: The number of entries to calculate over. Without it, every matching entry in the scope is used.
With two pairs, an entry has to match both. This adds up the same fields for the entries where Calculate is Yes and Number 2 is 6:
[gravitymath scope="view" id="8" secret="abc123" filter="filter_1=Yes&op_1=is&filter_3=6&op_3=is"]{Number 1:2}+{Number 2:3}[/gravitymath]filter_1 and op_1 apply to Calculate (field 1), and filter_3 and op_3 apply to Number 2 (field 3).
Each key is read once: if filter_3 appears twice, GravityMath uses only the last one. A second condition on the same field, such as a date range, needs the form ID before the field ID, as shown in Filtering by a date.
Filtering a choice field by its value #
For a choice field with Show Values checked, such as a drop down, the filter matches the choice’s value and not its label:

This adds up Number 1 for the entries where field 1 is First Choice:
[gravitymath scope="form" id="9" filter="filter_1=first_choice"]{Number 1:2:sum}[/gravitymath]Filtering by a date #
A date filter accepts the date in the Date field’s own format, as set in the form editor, or in the YYYY-MM-DD format. A date in any other format gives a wrong total: with is it matches nothing, and with gt or lt it can match every entry or none. On a form whose Date field (field 3) uses dd/mm/yyyy, this adds up field 4 for the entries dated May 7, 2025:
Total: [gravitymath scope="form" id="207" filter="filter_3=2025-05-07"]{Number:4:sum}[/gravitymath]With the shortcode placed under the View, the total counts the two entries from that day:

For a range, write the second condition with the form ID and a colon before the field ID, as in filter_207:3 and op_207:3. This needs GravityMath 2.12.3 or later. This adds up field 4 for the entries dated in May 2025:
Total: [gravitymath scope="form" id="207" filter="filter_3=2025-04-30&op_3=gt&filter_207:3=2025-06-01&op_207:3=lt"]{Number:4:sum}[/gravitymath]gt and lt leave out the dates you write, so the range starts after April 30 and ends before June 1. With scope="view" or scope="visible", use the ID of the View’s form. To filter by the date an entry was submitted, see Sum GravityMath values for today, a custom date range, or a rolling window.