Displaying the total amount raised


License Note

For this lesson you’ll need a GravityMath or a GravityKit All Access License.

In this lesson, we’re going to calculate and display the total amount raised using GravityMath! You can display the total amount raised at the bottom (or top) of your View, or you can show just the total amount raised by displaying the shortcode on your page.

Displaying the total amount raised at the bottom of your View

To add the total amount raised to the bottom of the View we created in the last lesson, scroll to the “Bottom Widgets” section of the View. Next, add a Custom Content widget to one of the widget areas.

Bottom widgets section with Custom Content field in top section

Now we can use the [gv_math] shortcode to calculate the total amount raised.

Enter the following shortcode into your Custom Content field (just make sure to replace the merge tags with your own): 

Total Raised: $[gv_math scope="form" id="38"] {Total:9:sum} [/gv_math]

Set the scope to “form” to calculate based on all the entries received for that form (this does not include entries in the trash). Then enter your form ID, which you can find in your list of forms. The first number to the right of your form title is the form ID.

The form ID for a form titled "Donations" in Gravity Forms

After the first set of brackets, which opens the formula, type a curly bracket (“{“) to see a list of available fields pop up. Choose the “Total” field to sum. After the field ID, inside the curly brackets, you’ll need to enter :sum, as shown in the shortcode above.

Once your formula is complete, close out the shortcode with [/gv_math].

Displaying the total amount raised on its own

To display the total amount raised on its own, paste the shortcode you created for the step above into a Gutenberg “Shortcode” block, or the block your theme uses to display shortcodes.