The {entry_count} merge tag in GravityMath
In a [gravitymath] shortcode, {entry_count} is replaced with a number of entries: those of the form, of the View, or of the current page of a View, depending on the shortcode’s scope. Entries in the trash or marked as spam are not counted.
Average per entry #
This divides the total of the Hours field (field 3) by the number of entries in form 27:
[gravitymath scope="form" id="27" decimals="2"] {Hours:3:sum} / {entry_count} [/gravitymath]With 22.5 hours over 8 entries, it shows 2.81. Entries with no hours count too. To leave them out, use {Hours:3:avg}, which shows 3.21 with the same decimals (22.5 hours over the 7 entries that have hours).
What it counts in each scope #
To choose the count yourself, add a modifier: {entry_count:form}, {entry_count:view} or {entry_count:visible}.
| Merge tag | scope="form" | scope="view" | scope="visible" |
|---|---|---|---|
{entry_count} | The form’s entries | The View’s entries | The entries on the current page |
{entry_count:form} | The form’s entries | The form’s entries | The form’s entries |
{entry_count:view} | 0 | The View’s entries | The View’s entries |
{entry_count:visible} | 0 | 0 | The entries on the current page |
The View’s entries follow a visitor’s search: after a search that finds 3 entries, {entry_count:view} is 3.
Counting the entries that match a filter #
{entry_count} ignores the shortcode’s filter. To count only the entries that match, use the :count modifier on a field every entry has a value in, such as {Plan:2:count}. The [gravitymath] shortcode has an example.