Custom search form to calculate average

By: François Carrier | Asked: 04/17/2023
ForumsCategory: General questionsCustom search form to calculate average
François Carrier asked 12 months ago

Hello everyone !

I have a question that I have not found the answer on this forum.  I have a form with 2 entries: the neighborhood (id=40) and the price (id=13). The neighborhood is a dropdown list and the price is a numerical value. I would like to have a way to search through this form to select for example "Rich neighborhood" and then calculate (and display) the average of all entries from that neighboorhood only. This should be displayed as a single number (not a list of all price entries for that particular neighborhood).

I have followed this totorial: https://formidableforms.com/knowledgebase/create-custom-search-form/.

As a result, I have created a second form to search through the first one. In this second form, the only field is the neighborhood (id = 42). This field has the following default value: [get param= montreal.neighborhood]. Then, in Formidable Views, I place the second form (id =5) and apply a filter "like" [get param= neighborhoods].

 

When I test it, I can see all data showing on Views. When I select the neighborhood trhough the second form, it works in the way that it is showing only data cards from that selected neighborhood. However, this is not what I want. Right now, if I have 1000 entries, it is showing me all 1000 entries.I want to show a single data card displaying the average value of all data cards. 

I don't know what to put in the the "page content" to display the result. Right now, I have tried:

  • [frm-stats id=13 type=average where="40=:[get param=neighborhood]"] $CAD // This is not working, it is showing 0 and it is showing a list of al data. 
  • [frm-stats id=13 type=average] // this is not working as this is showing the average price from ALL entries (not just the one the user entered in the second form).

Would I need a custom PHP script to do this?

Anyway, any kind of help would be appreciated! 

Thank you very much,

Francois

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right