Title: Calculating an average
Last modified: January 7, 2017

---

# Calculating an average

 *  Resolved [chadtesting](https://wordpress.org/support/users/chadtesting/)
 * (@chadtesting)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/calculating-an-average/)
 * Sorry if this question has been asked before, but I’m having trouble finding 
   the proper operators to calculate an average.
 * I have 4 fields
 * fieldname1
    fieldname2 fieldname3 fieldname4
 * The user does not have to fill out all the fields, but of the ones filled out,
   I need to calculate an average. I can’t just use 1+2+3+4/4 – I have to set it
   so that it calculated the average of only the fields filled out.
 * Can someone help?

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/calculating-an-average/#post-8629325)
 * Hello,
 * The process is very simple, you should check if the field has assigned a value
   to increase a counter that will be used to calculate the average, similar to 
   the following code:
 *     ```
       (function(){
       var values = [fieldname1,fieldname2,fieldname3, fieldname4],
           total = 0,
           counter = 0;
   
       for(var i in values)
       {
       if(values[i]) counter++;
       total += values[i];
       }
   
       return (counter)?total/counter:0;
       })()
       ```
   
 * and that’s all.
    Best regards.
 *  Thread Starter [chadtesting](https://wordpress.org/support/users/chadtesting/)
 * (@chadtesting)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/calculating-an-average/#post-8634654)
 * That worked brilliantly.
 * The problem I’m finding (and I think I’ll continue to find) as I work through
   my project, is that while I am smart enough to ask good questions and figure 
   out how to apply your solutions, I don’t have the ability to code this project
   outside of the nice little walled garden you’ve made for us.
 * By the time I’m done, I want to have multiple levels of conditional show/hide
   logic based on calculating half a dozen data points, some which are numeric ranges,
   and some which are true/false. I just don’t see me being able to do this properly,
   even if I buy the retail version, without a solid foundation in javascript, Jquery,
   and CSS. Please tell me I’m wrong 🙂
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/calculating-an-average/#post-8635241)
 * Hello [@chadtesting](https://wordpress.org/support/users/chadtesting/),
 * The skills required to use our plugin depends of the project’s complexity. The
   plugin is very versatile and give the user the possibility to implement all type
   of projects. If you want to implement complex formulas for checking numeric ranges,
   show/hide fields based on complex conditions, then, you might need some additional
   skills.
 * Best regards.
 *  Thread Starter [chadtesting](https://wordpress.org/support/users/chadtesting/)
 * (@chadtesting)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/calculating-an-average/#post-8635310)
 * So my next question is, do you charge an hourly rate to help round out existing
   projects given specifications?
 * Because I feel like I can take this so far with your plugin, but then I will 
   need some dedicated hours of your time to finish the project.
 * The upside to this is that I will have a good understanding of the plugin to 
   make changes within it once you are finished, and I can work with you in the 
   future.
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/calculating-an-average/#post-8635593)
 * Hello [@chadtesting](https://wordpress.org/support/users/chadtesting/),
 * Yes of course, please, send me the project’s specifications through my personal
   website:
 * [http://cff.dwbooster.com/customization](http://cff.dwbooster.com/customization)
 * Best regards.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Calculating an average’ is closed to new replies.

 * ![](https://ps.w.org/calculated-fields-form/assets/icon-256x256.jpg?rev=1734377)
 * [Calculated Fields Form](https://wordpress.org/plugins/calculated-fields-form/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/calculated-fields-form/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/calculated-fields-form/)
 * [Active Topics](https://wordpress.org/support/plugin/calculated-fields-form/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/calculated-fields-form/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/calculated-fields-form/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [codepeople](https://wordpress.org/support/users/codepeople/)
 * Last activity: [9 years, 5 months ago](https://wordpress.org/support/topic/calculating-an-average/#post-8635593)
 * Status: resolved