How to display summaries using a block, widget, or shortcode
A GravityMath summary groups entries by the value of one field and calculates a result for each group, such as the total revenue of each sector or the number of entries in each category. It shows the result as a table. Add one with the GravityMath Summary block, with the [gravitymath] shortcode, or with the Math Summary widget in a View.
Add a summary with the block #
- In the block editor, add the GravityMath Summary block.
- In the block settings, under Select a source, choose Form or View, then pick it in Select a form or Select a View.
- Choose the field to group entries by in Group by.
- Choose the Operation: Count, Sum, Average, Min or Max. For every operation except Count, choose the field to calculate in Apply to.
The block shows the table as you change the settings:

The other settings:
- Decimals: the number of decimal places. Left empty, the result keeps every decimal the calculation returns, such as 6,076.66666667 for an average.
- Sort By: Field (ASC) and Field (DESC) sort by the group names, Lowest First and Highest First by the result.
- Display: All groups, or the first 3, 5 or 10 in the sort order.
- Use values for labels: for a choice field whose choices have separate values, the table shows the choice labels. Turn this on to show the stored values instead.
- Group By Label and Operation Label: the column headings. They default to the field’s label and the operation’s name.
Add a summary with the shortcode #
This shortcode adds up field 3 (Revenue) of form 37 for each value of field 2 (Sector), highest first:
[gravitymath action="summary" form_id="37" group_by="2" operation="sum" number_field="3" sort_by="math-desc"]| Attribute | Value |
|---|---|
form_id | The ID of the form. |
id | The ID of a View, in place of form_id. |
group_by | The ID of the field to group entries by. |
operation | count (the default), sum, avg, min or max. |
number_field | The ID of the field to calculate. Every operation except count needs it. |
sort_by | field-asc (the default) or field-desc to sort by the group names, math-asc or math-desc to sort by the result. |
display | all (the default), top3, top5 or top10. |
decimals | The number of decimal places. |
group_by_label, operation_label | The column headings. |
use_values | true shows the stored values of a choice field in place of its labels. |
filter | Limits the summary to the entries that match, as in filter="filter_4=500&op_4=gt". Math filters explains the syntax. |
Add a summary to a View with the widget #
The Math Summary widget follows the View: when a visitor searches, the summary covers only the entries found. In a DataTables View, a summary of the Entries shown on the page also changes when a visitor opens another page or sorts the table, in both processing modes.
- Edit your View, click Add Widget in a widget area, and choose Math Summary.
- Click the widget’s gear icon to open Math Summary Settings.
- Choose Group By, Operation and Apply To, and the other settings, which work as in the block.
- Under Display summary for:, choose All View entries, or Entries shown on the page for a summary of the current page only.

Things to know #
- The group names are plain text, so a summary row doesn’t link to its entries. Linking each group to its entries shows a way to list the groups as links.
- A summary shows nothing when a setting it needs is missing, such as Group by, or Apply to for an operation other than Count.
- Average, Min, and Max leave out entries without a value in the Apply to field, and a group whose entries all have no value in it gets no row.
- A Checkbox field is calculated from the values of its checked choices: Sum adds them all, and Max gives the highest checked value. An Option field is calculated from its price.
- Survey questions of the Likert, Rank, and Rating types aren’t offered in Group by or Apply to. Survey questions with radio buttons or checkboxes can group entries, and so can a drop down question. The summary shows their choice labels.
Linking each group to its entries #
To list each group as a link to its entries, with its total, use a second form that holds one entry per group and a View of that form. In this example, a volunteer hours form has a Fiscal Year field (field 9) and a Volunteer Hours field (field 4). A Table View of it, View 12, is on a page at /volunteer-hours/.
- Add the Fiscal Year field to the Search Bar of View 12. A link with
?filter_9=in its address filters the View only when the field is in its Search Bar. - Create a form named Fiscal Years with one Single Line Text field, Fiscal Year. Add one entry per year, written exactly as the volunteer hours form stores it, spaces and dashes included, such as
2025 - 2026. - Create a Table View of the Fiscal Years form and add two Custom Content fields. The first links the year to its entries:
<a href="/volunteer-hours/?filter_9={Fiscal Year:1:urlencode}">{Fiscal Year:1}</a>The second adds up the year’s hours in View 12:
[gravitymath scope="view" id="12" secret="YOUR_VIEW_SECRET" filter="filter_9={Fiscal Year:1}"]{Volunteer Hours:4:sum}[/gravitymath]- Embed this View on a page of its own. On the page with View 12, the year in the address would filter these totals too.

Clicking a year opens View 12 with that year’s entries only. In the shortcode, {Fiscal Year:1} comes from the Fiscal Years form, while filter_9 and {Volunteer Hours:4:sum} refer to View 12’s form.
- With Enable Enhanced Security on for View 12, put its secret in place of
YOUR_VIEW_SECRET, or the totals stay empty. Enable Enhanced Security: the secret attribute for shortcodes shows where to copy it. - If the Fiscal Years form has a field with the same ID as Volunteer Hours, the totals are empty too. Using GravityMath inside a GravityView Custom Content field shows how to keep that merge tag for GravityMath.
