Title: Exclude field from calculation
Last modified: April 27, 2022

---

# Exclude field from calculation

 *  Resolved [coolwen22](https://wordpress.org/support/users/coolwen22/)
 * (@coolwen22)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/exclude-field-from-calculation/)
 * Hi! First of all, awesome plugin and support you are giving here!
 * I wish to exclude some fields from the calculation if the field beside them are
   empty. How can I achieve this?
 * Example:
 * fieldname1 — fieldname2
    fieldname3 — fieldname4
 * Fieldname2 and fieldname4 should be excluded from the calculation if fieldname1
   and fieldname3 are empty.
 * Hope I make this clear. Thanks!

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

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/exclude-field-from-calculation/#post-15597026)
 * Hello [@coolwen22](https://wordpress.org/support/users/coolwen22/)
 * Thank you very much for using our plugin. The code to use depends on the equation
   you want to implement. I’ll try to describe the process with two hypothetical
   examples.
 * Assuming you have the equation:
 * `fieldname2+fieldname4+fieldname9+fieldname10`
 * And you want to exclude the fieldname2 and fieldname4 from the sum if fieldname1
   and fieldname3 are empty, respectively.
 * The equation can be implemented as follows:
 * `IF(fieldname1|r == '', 0, fieldname2)+IF(fieldname3|r == '', 0, fieldname4)+
   fieldname9+fieldname10`
 * The equation includes the `IF` operation and checks the raw values of fieldname1
   and fieldname3 by using the `|r` modifier. In this first example, the alternative
   value is the number zero because it does not modify the sum result.
 * Now, if we use the multiplication instead of the sum operator:
 * `fieldname2*fieldname4*fieldname9*fieldname10`
 * The zero is not an alternative in this case because affects the result. The modification
   in this case would be:
 * `IF(fieldname1|r == '', 1, fieldname2)*IF(fieldname3|r == '', 1, fieldname4)*
   fieldname9*fieldname10`
 * Now the alternative value is the one.
 * Best regards.
 *  Thread Starter [coolwen22](https://wordpress.org/support/users/coolwen22/)
 * (@coolwen22)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/exclude-field-from-calculation/#post-15597127)
 * Works like a charm! Thank you!

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

The topic ‘Exclude field from calculation’ 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/)

 * 2 replies
 * 2 participants
 * Last reply from: [coolwen22](https://wordpress.org/support/users/coolwen22/)
 * Last activity: [3 years, 11 months ago](https://wordpress.org/support/topic/exclude-field-from-calculation/#post-15597127)
 * Status: resolved