How to display summaries using a block, widget, or shortcode

You may want to group Gravity Forms entries by a specific field value and then perform math operations on entries within those groups. 

Here’s an example: You have a form for collecting data on companies and you want to know what the average profit is for companies in each industry.

A Summary Report. It's a table with two columns: 'Industry' and 'Average profit (millions)'.

There are 3 ways to do this:

  1. Using a WordPress block (data source can be a form or View)
  2. Using a shortcode (data source can be a form or View)
  3. Using the GravityView widget (only works if your data source is a View)

Prefer to watch the video?

Here are our form entries. As you can see, each entry represents a single company, including its industry, sector, market cap, revenue, and profit. Now let's create a Summary Report to show the average profit per industry!

Form entries

Using the block

Start by editing an existing page/post or create a new one. Next, add the "GravityMath Summary" block to your page.

The GravityMath Summary block in the WordPress block editor

Now open the block settings on the right to configure the Summary Report.

Start by selecting a data source. This can be any form or View on your site. As you configure the report, the preview will update in real time. Here’s a list of the options to configure:

  • Group by – The field you want to group entries by.
  • Operation – The mathematical operation to perform (either count, sum, average, max or min).
  • Apply to – The field you want to perform the operation on.
  • Decimals – The number of decimal places for the output.
  • Sort by – Sort output ASC or DESC.
  • Display – The number of rows to display in the summary.
  • Group by label – The group by column title. 
  • Operation label – The operation column title.

The GravityMath Summary block settings

Using the shortcode

You can also create Summary Reports using the [GravityMath] shortcode.

If your data source is a form:

[gravitymath action="summary" form_id="1" group_by="1" operation="SUM" number_field="3"]

The group_by and number_field parameters require a field ID as a value.

If your data source is a View, simply replace the form_id parameter with id and set it equal to your View's ID.

Several other shortcode parameters are also supported:

  • decimals – Can be 0, 1, 2, 3, etc depending on how many decimal places you want.
  • sort_by – Either math-asc,  math-desc,  field-asc or  field-desc  where math  represents the outcome of the operation, and field  represents the group by field value.
  • display – Either all (default), top3,  top5  or top10.
  • group_by_label  – The label used for the field column in the output table. Defaults to the name of the field.
  • operation_label  – The label for the operation column in the output table. Defaults to the operation used.

Using the GravityView widget

If you want to add a Summary Report to a View that updates automatically when searches are performed, you can use the GravityMath Summary widget.

Simply edit your View, click on "Add Widget" and select "Math Summary".

Math Summary widget

After adding the widget to your View, click on the gear icon to open the widget settings. Here, you can configure the Summary Report.

The Math Summary widgets settings in GravityView

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

Still need help? Contact Us Contact Us