Using ws_form_stat to Show Submission Statistics

When asking questions in a form using choice fields such as select, checkbox or radio fields you may wish to obtain statistics about the answers given. You can use the ws_form_stat shortcode to do this.

Demo

Form Statistics

Total Responses: 67

Early bird: 35 (52%)
Night owl: 32 (48%)

Usage

The ws_form_stat shortcode can contain the following attributes:

Attribute Description Default
field_id The field ID you wish to obtain statistics for.
type Choose count or percent.
value Optionally enter a value you would like to obtain statistics for.
decimals Number of decimals to include in the returned statistic. 0
thousand_separator The character to use as the thousand separator. ,
decimal_separator The character to use as the decimal separator. .

Examples

Shortcode Description Example
[ws_form_stat field_id="123" type="count"] Return the total number of submissions for field ID 123. 67
[ws_form_stat field_id="123" type="count" value="Early bird"] Return the total number of submissions for field ID 123 that chose the value “Early bird”. 35
[ws_form_stat field_id="123" type="percent" value="Early bird"] Return the percent of submissions for field ID 123 that chose the value “Early bird”. 52%
[ws_form_stat field_id="123" type="percent" value="Early bird" decimal="2"] Return the percent of submissions for field ID 123 that chose the value “Early bird” to 2 decimal places. 52.24%