How to target a specific field value with [gv_math] filters

Assuming you have a form like this one:

...and a View like this one:

Now, you want to calculate the sum between Number 1 and Number 2, only for the entries where the value of the Calculate field is "Yes". That's now possible with the "filter" parameter of the [gv_math] shortcode.

Here's our shortcode:

	Total: [gv_math scope="view" id="206" filter="filter_1=Yes&op_1=is"]{Number 1:2}+{Number 2:3}[/gv_math]

and here's the output in the View:

Usage


The following attributes for the "filter" parameter are supported:

filter_N - the filter, where N is the ID of the field or meta key
op_N - the operation for a corresponding filter_N, default: is, other operatores are isnot, contains, notcontains, lt (less than), and gt (greather than).
limit - the number of entries to calculate. Leave it blank to use all entries from the chosen "scope" parameter.

In the example below, we are filtering the field Calculate (ID = 1) for the "Yes" value.

[gv_math scope="view" id="206" filter="filter_1=Yes&op_1=is"]...[/gv_math]

If we wanted to filter by two fields instead, for example, Calculate =Yes and Number 2 = 6, then we'll do it like this:

[gv_math scope="view" id="206" filter="filter_1=Yes&op_1=is&filter_3=Yes&op_3=is"]...[/gv_math]

pay attention to the fact that filter_1 and op_1 correspond to the first field Calculate (ID = 1) and filter_3 and op_3 correspond to the field Number 2 (where ID = 3).

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.