The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group

Slack Signup
Newsletter Optin
Help Desk

Display totals based on filtered entries of a view

Labels

This Discussion is public

Notifications

Hello,

I've created a page which contains a search form for filtering entries of a View. This works fine.

However, I want to display some totals of the filtered entries. When the filter is not used, a total is calculated using all entries. When the filter is used, a total is calculated using all filtered entries. How can this be achieved?

Thanks in advance.

Eric

 

Hi Eric,

Could you describe more about your total calculation? Is it a total of a number field value?

Also, have a look at "frm_stats" shortcode where you can add filters for your calculations. https://formidableforms.com/knowledgebase/add-field-totals-and-statistics/

Hello Sujeevan,

Thanks for your response.

The total calculation is needed for total - and number field values.

I'm aware of the possibilites of the "frm_stats" shortcode, however that information does not describe a solution for me. Let me explain my request in more detail.

The shortcode [frm-stats id=x type=total 25="Yes"] filters entries where field 25 = "Yes". I want to filter entries based on a value that's in the url. For example: .../?BTW=&EI=&VAL=&CAT=.

EI can be "Yes" or "No".

Instead of using [... type=total 25="Yes"] I need "Yes to be replaced by the content of the parameter EI (which is "Yes" or "No"). How to achieve this?

Regards,

Eric

 

Hi Eric,

Could you give a try the followings,

[frm-stats id=x type=total 25=[get param="EI"]]

More info about get param shortcode is here - https://formidableforms.com/knowledgebase/using-dynamic-default-values-in-fields/#kb-get-a-parameter-from-the-url

On a related note, if you simply wants display number of filtered records, [entry_count] shortcode could be used - https://formidableforms.com/knowledgebase/insert-fields/#kb-entry-count

Hi Sujeevan,

It seems to work.

Thanks!!!

Eric

Hi Sujeevan,

It seems to work a bit. When I use more fields for filtering and these are all optional to fill in, it dos not work.

I've four optional fields in the search form. If nothing is filled in, all entries are displayed. This is ok and the totals of al entries should be calculated. If one or more of the four fields of the search form are filled in, only the filtered entries are displayed. This is ok. However, only the totals of the filtered entries should be calculated. I'm working on a solution and the shortcode [frm-stats id=701 type=count 689=[get param="VAL"] 690=[get param="BTW"] 701=[get param="EI"] 718=[get param="CAT"]]
works in general, but I've to do more digging. Any ideas?

Regards,

Eric

Hi Eric,
If the search form field is optional, it will be an issue as the filter in "frm_stats" doesn't seems to ignore missing/null condition value.

I can think about two solutions

1. I noticed that you are using type=count - If you simply want to count the number of filtered rows, adding [entry_count] shortcode in your View is the best solution. "entry_count" will only count filtered rows. You could add it to your View "before content" or "after content" otherwise it would repeat for each row.

2. If you like to use other types of aggregations such as total, average, median, ...etc, the best way I could think about it using PHP alternative to frm_stats where you can skip optional field with no values programmatically. https://formidableforms.com/knowledgebase/add-field-totals-and-statistics/#kb-php-alternative

Hi Sujeevan,

Thanks again for your feedback.

Eric

Discussion closed.