Title: Calculation question
Last modified: August 31, 2016

---

# Calculation question

 *  Resolved [tobi1982](https://wordpress.org/support/users/tobi1982/)
 * (@tobi1982)
 * [10 years ago](https://wordpress.org/support/topic/calculation-question/)
 * Hi,
    I try to realise a calculater that calculates the Resting Metabolic Rate.
 * I used a drow down field to choose men or women because the calculation is different.
 * So i have to differentiate between men and women. How do you do a “If” calculation
   in the equoation:
 * this is the quation for men:
    10*fieldname2+6.25*fieldname4-5*fieldname3+5
 * Screenshot: [http://www.online-fitness-coaching.com/wp-content/uploads/2016/03/calories.jpg](http://www.online-fitness-coaching.com/wp-content/uploads/2016/03/calories.jpg)
 * [https://wordpress.org/plugins/calculated-fields-form/](https://wordpress.org/plugins/calculated-fields-form/)

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

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [10 years ago](https://wordpress.org/support/topic/calculation-question/#post-7210564)
 * Hi,
 * You should use the “IF” operation in the equation:
 * `IF(condition, result if condition is true, result if the condition is false)`
 * For example, if the Drop Down field is the fieldname1, and the values of its 
   choices are: man and woman, furthermore, if the operation for men is:
 * `10*fieldname2+6.25*fieldname4-5*fieldname3+5`
 * and for women is:
 * `10*fieldname2+6.25*fieldname4-5*fieldname3+3.5`
 * the equation should be edited as follows:
 * `IF(fieldname1 == 'man', 10*fieldname2+6.25*fieldname4-5*fieldname3+5, 10*fieldname2
   +6.25*fieldname4-5*fieldname3+3.5)`
 * Best regards.
 *  Thread Starter [tobi1982](https://wordpress.org/support/users/tobi1982/)
 * (@tobi1982)
 * [10 years ago](https://wordpress.org/support/topic/calculation-question/#post-7210651)
 * Thank you this already helped alot.
 * But I’m facing the next problem. In an additional drop down field the user can
   choose his activity level. So i guess i need to add an additional IF condition,
   but this time not only for 2 but for 4 variables.
 * 1: low (last result*1,2)
    2: medium (last result*1,55) 3: high (last result*1,75)
   4: very high (last result*1,9)
 * Can you help me?
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [10 years ago](https://wordpress.org/support/topic/calculation-question/#post-7210652)
 * Hi,
 * Assuming the Drop Down field is the fieldname1, and the last result is the fieldname2,
   the equation should be similar to:
 *     ```
       (function(){
       var n = 1;
       switch(fieldname1)
       {
       case 'low': n = 1.2; break;
       case 'medium': n = 1.55; break;
       case 'high': n = 1.75; break;
       case 'very high': n = 1.9; break;
       }
       return fieldname2*n;
       })()
       ```
   
 * If you need additional help with your equation, please, request a custom coding
   service through my private website:
 * [http://cff.dwbooster.com/customization](http://cff.dwbooster.com/customization)
 * Best regards.

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

The topic ‘Calculation question’ 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/)

 * 3 replies
 * 2 participants
 * Last reply from: [codepeople](https://wordpress.org/support/users/codepeople/)
 * Last activity: [10 years ago](https://wordpress.org/support/topic/calculation-question/#post-7210652)
 * Status: resolved