Title: Exclude empty fields
Last modified: May 9, 2021

---

# Exclude empty fields

 *  Resolved [sephan](https://wordpress.org/support/users/sephan/)
 * (@sephan)
 * [5 years ago](https://wordpress.org/support/topic/exclude-empty-fields/)
 * Hey there, I have a big problem and no idea how to solve it.
 * Basically, I want to create a form with 10 Field Type: Number, fields and 1 Field
   Type: Calculated Field, field. All those 10 fields are mentioned within the calculation
   field BUT the user will only fill out any 4 of those fields. I will attach screenshots
   to make the situation more understandable (sorry for the trouble).
 * My problem is, due to the equation I use, the empty fields still have an influence
   on the calculation field, and that’s bad. I cold use predefined numbers, which
   will result in a 0 so the empty fields won’t have an influence. But I can’t change
   the mode to “placeholder”, because then the numbers aren’t counted anymore.
    
   Also, I cannot use Dropdown menus, because when I create 4 Dropdown menus for
   the user, to choose what 4 values he needs to fill out, the other 6 unchosen 
   and predefined values are not counted anymore.
 * So there are 3 options in my mind:
 * 1. Exclude empty fields from the equation: If it would be possible to do that,
   I could remove the predefined values and users can just fill out 4 fields.
 * 2. Make unchose dropdown options count: I guess that would be the best solution,
   if possible. The predefined values prevent a wrong equation, and the user can
   just choose which fields they need to fill out.
 * 3. Make “placeholders” count: If it would be possible to make placeholders count,
   the user would not be able to empty the field. Not the best option but still 
   considerable.
 * I hope my problem became clear. The equation you can see in the screenshot only
   contains 2 fields atm, but the other 8 fields will be added with the same method.
   
   Sorry for my bad English and I’m very thankful for any help.
 * [https://imgur.com/a/rXLIrzS](https://imgur.com/a/rXLIrzS)

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

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [5 years ago](https://wordpress.org/support/topic/exclude-empty-fields/#post-14417886)
 * Hello [@sephan](https://wordpress.org/support/users/sephan/)
 * The easiest solution would be to define dependencies.
 * For example, if the number fields depend on the choice selected in the Dropdown
   fields, you can configure these fields as dependent on the corresponding Dropdown
   choices.
 * But you keep in mind the values of the dependent fields are zero when they are
   disabled. So, the disabled fields do not affect the sum operation.
 * For example, assuming you have a dropdown field with three choices and three 
   number fields, fieldname1, fieldname2, and fieldname3. Each of them is defined
   as dependent on the corresponding choices in the dropdown field. And you want
   to duplicate the number entered by the user.
 * The equation in this hypothetical example can be implemented as follows because
   only the active field will affect the sum:
 * `(fieldname1+fieldname2+fieldname3)*2`
 * More information about dependencies by reading the following post in the plugin’s
   blog:
 * [https://cff.dwbooster.com/blog/2020/03/01/dependencies](https://cff.dwbooster.com/blog/2020/03/01/dependencies)
 * Best regards.
 *  Thread Starter [sephan](https://wordpress.org/support/users/sephan/)
 * (@sephan)
 * [5 years ago](https://wordpress.org/support/topic/exclude-empty-fields/#post-14424464)
 * No sorry, I guess you have not caught the problem. I already did all of that.
 * My problem: Due to the equation, my result goes wrong when a number field is 
   not filled out, because i want only the filled fields to be calculated. Equation
   example short:
 * > ((fieldname1-209)/18.4)+((fieldname2-14)/1.15)+((fieldname3-16)/1.17)
 * Example: Now to make my problem clear I use a small example with 3 fields:
 * > Let’s say I fill out “fieldname1” and “fieldname2”. “fieldname3” stays empty.
   > 
   > Now, when I start the calculation, the equation just goes: ((fieldname1-209)/
   > 18.4)+((fieldname2-14)/1.15)+((0-16)/1.17)
 * The problem ends up in: Empty fields will cause a false result because the result
   will be subtracted by the equation of the empty fields.
 * To prevent this: I started to use predefined values, but in dropdown menus, only
   the chosen option is calculated.
 * Solution: I want to make the predefined value of unchosen fields count.
 * Condition: In the end, I will have 10 number fields, each mentioned within the
   equation like in the example above, but the user will only fill out 4 of these
   fields, depending on their own conditions.
    -  This reply was modified 5 years ago by [sephan](https://wordpress.org/support/users/sephan/).
    -  This reply was modified 5 years ago by [sephan](https://wordpress.org/support/users/sephan/).
    -  This reply was modified 5 years ago by [sephan](https://wordpress.org/support/users/sephan/).
    -  This reply was modified 5 years ago by [sephan](https://wordpress.org/support/users/sephan/).
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [5 years ago](https://wordpress.org/support/topic/exclude-empty-fields/#post-14424527)
 * Hello [@sephan](https://wordpress.org/support/users/sephan/)
 * In this case, you should use conditional operations in the equation to prevent
   its evaluation until all its operands contain a value. Something like:
 * `IF(AND(fieldname1, fieldname2, fieldname3), (fieldname1-209)/18.4+(fieldname2-
   14)/1.15+(fieldname3-16)/1.17, '')`
 * Best regards.
 *  Thread Starter [sephan](https://wordpress.org/support/users/sephan/)
 * (@sephan)
 * [5 years ago](https://wordpress.org/support/topic/exclude-empty-fields/#post-14424610)
 * Tyvm for all your help! This works out. Great plugin, lovin it!

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

The topic ‘Exclude empty fields’ 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/)

## Tags

 * [empty](https://wordpress.org/support/topic-tag/empty/)
 * [equation](https://wordpress.org/support/topic-tag/equation/)

 * 4 replies
 * 2 participants
 * Last reply from: [sephan](https://wordpress.org/support/users/sephan/)
 * Last activity: [5 years ago](https://wordpress.org/support/topic/exclude-empty-fields/#post-14424610)
 * Status: resolved