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.
- 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. A summary row doesn’t link to the entries behind it.
- A summary shows nothing when a setting it needs is missing, such as Group by, or Apply to for an operation other than Count.