How to calculate the sum of a field in Gravity Forms
Using Math by GravityView, we can use the [gv_math]
shortcode to add up the values of all the entries in the form.
We need two things to find the total value of a field for all form entries:
- The Form ID
- The Merge Tag of the field we want to sum
1. Finding your Form ID

The Form ID is easy to find: it's next to the name of the form on the Edit Form screen in Gravity Forms.
You can use the Form ID in the [gv_math]
shortcode when using scope="form"
.
2. Finding the field's Merge Tag

The Merge Tag is formatted like this: {Name of Field:Field ID}
. This can sometimes be hard to find, so here is how to find it:
In the Gravity Forms form toolbar, hover over Settings and click on Notifications

Click Add New to create a new Notification

We're not going to save it, this is just to get the correct Merge Tag.
Click on the Merge Tag icon

It's a small little button next to inputs.
Click on the field you want to use for the calculation

There's the Merge Tag!

You can use this Merge Tag inside a [gv_math]
shortcode.
To retrieve the total number of attendees for this form (Form ID #1), we would use the following shortcode:
[gv_math scope="form" id="1"] {Number of Attendees:12} [/gv_math]
That will automatically sum the total of the attendees.
Where can I add the [gv_math] shortcode?

You can add the shortcode most anywhere!
If you want to insert the shortcode inside Page or Post content, go ahead. Here, we show the shortcode added to a "Planning the Event" page where we want to show the sum of the "Number of Attendees" field values.
Adding the shortcode to a Page

You can add the shortcode most anywhere!
If you want to insert the shortcode inside Page or Post content, go ahead. Here, we show the shortcode added to a "Planning the Event" page where we want to show the sum of the "Number of Attendees" field values.
On the front-end of the site, the shortcode is replaced

The shortcode will be swapped out with a live number of attendees based on the field values.
Adding the shortcode to a GravityView Custom Content widget
If you want to add a shortcode to a View, you can do that using the Custom Content widget ( or field).
Click "Add Widget" button in the View Configuration screen

Click "Custom Content" to add a widget

Click the gear icon to configure the widget

Update the Custom Content text to include the shortcode

Here, I wrap the shortcode in <strong>
, which will make it appear bold.
And voilá! Your attendee count is shown in the Custom Content widget output
