Get the sum total from a field across all entries

Can it be done?

I want to create a historical ‘balance’ based on previous form submissions, which means I’d like to add together all previous number field entries… *Note, I don’t want to publish the number externally of the form (I’m aware that you can perform this kind of action with short codes like gravity math and Gravity View also does something similar). I wan’t to perform the data retrieval and calculation INSIDE the form, like {total:9:sum} kinda thing.

Thanks

Hi Mark. If you have access to GravityKit, I suspect the [gravitymath] shortcode could do this:

You could call that in a function to populate a field in the form before the form is rendered, using the gform_field_value filter:

If you don’t have access to that, you could create your own shortcode and use a PHP function with the GFAPI to total all the values submitted for one field in a single form across all entries.

Or, still using GFAPI, you could use the gform_custom_merge tag filter:

Or gform_merge_tag_filter:

With any solution you code yourself, you will be using the GFAPI class to get the values from the entries:

If you need any other ideas, please let us know.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.