Title: IF equation problem
Last modified: April 22, 2020

---

# IF equation problem

 *  Resolved [svd89](https://wordpress.org/support/users/svd89/)
 * (@svd89)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/if-equation-problem/)
 * Hi Codepeople,
 * How are you doing? I was wondering if you could provide me some help with the
   translation of the following excelformula (IF) to the ‘Advanced Equation Field’:
 *     ```
       IF(fieldname3=1,fieldname4*100%,fieldname4*100%,
       IF(fieldname3=2,fieldname4*70%,fieldname4*100%,
       IF(fieldname3=3,fieldname4*70%,fieldname4*100%,
       IF(fieldname3=5,fieldname4*60%,fieldname4*100%,
       IF(fieldname3=6,fieldname4*60%,fieldname4*100%,
       IF(fieldname3>=7,fieldname4*50%,fieldname4*100%))))))
       ```
   
 * I’ve tried loads of things but unfortunately I will not be able to get it work.
   What am I doing wrong? I hope you can help me out. Many thanks in advance and
   have a good day!
 * Best regards,
    Stefanie

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

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/if-equation-problem/#post-12713177)
 * Hello [@svd89](https://wordpress.org/support/users/svd89/)
 * Your equation includes multiple errors:
 * First, in javascript the operator for equality is the double symbol “==”, because
   the symbol “=” is used for assignment.
 * Second, if you want to get the X percentage of the Y number the correct operation
   would be: Y*X/100 and not fieldname4*100%
 * Third, the “IF” operation requires three parameters: condition, result if condition
   is true, and result if condition is false. In you equation you are using four
   parameters.
 * You can nesting IF operations, but using them as one of three parameters.
 * The equation could be implemented as follows:
 *     ```
       IF(fieldname3==1, fieldname4, IF(fieldname3<=3, fieldname4*0.7, IF(fieldname3<=6, fieldname4*0.6, fieldname4*0.5)))
       ```
   
 * Best regards.
 *  Thread Starter [svd89](https://wordpress.org/support/users/svd89/)
 * (@svd89)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/if-equation-problem/#post-12713305)
 * Yes, it works! You made my day.
    Thank you very much!
 * Best regards,
    Stefanie
 *  Thread Starter [svd89](https://wordpress.org/support/users/svd89/)
 * (@svd89)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/if-equation-problem/#post-12729269)
 * Hi Codepeople,
 * Here I am again 🙂
    About the previous equation..How can I replace [fieldname4*
   xx] in some text? For example:
 * `IF(fieldname3==1, no discount, IF(fieldname3<=3, 30% discount, IF(fieldname3
   <=6, 40% discount, 50%)))`
 * I hope to hear from you. Many thanks in advance and have a nice weekend!
 * Best regards,
    Stefanie
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/if-equation-problem/#post-12729273)
 * Hello [@svd89](https://wordpress.org/support/users/svd89/)
 * In javascript the texts must be enclosed between single or double quotes, so 
   the equation would be:
 *     ```
       IF(fieldname3==1, 'no discount', IF(fieldname3<=3, '30% discount', IF(fieldname3<=6, '40% discount', '50%')))
       ```
   
 * Best regards.
 *  Thread Starter [svd89](https://wordpress.org/support/users/svd89/)
 * (@svd89)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/if-equation-problem/#post-12729335)
 * Great! Thank you very much again!

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

The topic ‘IF equation problem’ 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: [svd89](https://wordpress.org/support/users/svd89/)
 * Last activity: [6 years, 1 month ago](https://wordpress.org/support/topic/if-equation-problem/#post-12729335)
 * Status: resolved