• Resolved sephan

    (@sephan)


    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

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @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

    Best regards.

    Thread Starter sephan

    (@sephan)

    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 3 years, 9 months ago by sephan.
    • This reply was modified 3 years, 9 months ago by sephan.
    • This reply was modified 3 years, 9 months ago by sephan.
    • This reply was modified 3 years, 9 months ago by sephan.
    Plugin Author codepeople

    (@codepeople)

    Hello @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

    (@sephan)

    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.