PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

conditional statements and values from multiple fields in calculation formulas?

  1. sydeburn
    Member

    Is it possible to use conditional statements and values from multiple fields in calculation formulas? For example, say I have a number field called calc1, and I apply a formula to it. I want the value to be calculated based on what was answered in previous questions q1 and q2:

    calc1 = 2 if (q1==yes AND q2==yes)
    else
    calc1=1 if (q1==yes OR q2==yes)
    else
    calc1=0

    Thanks in advance.

    Posted 11 years ago on Thursday November 29, 2012 | Permalink
  2. Conditional statements are not supported in the calculations. You might be able to do this with conditional logic but I'm unclear what it is you need to do based on your question.

    Posted 11 years ago on Thursday November 29, 2012 | Permalink
  3. sydeburn
    Member

    What I want to do is show/store a value based on the way multiple questions were answered. In my example above, I'm saying I want to show "2" if the user answered "yes" to BOTH questions A and B, or show "1" if the user answered yes to EITHER A or B.

    Posted 11 years ago on Tuesday December 4, 2012 | Permalink
  4. If you need that information stored in the entry, but it does not need to be shown on screen, you can use the gform_pre_submission filter http://www.gravityhelp.com/documentation/page/Gform_pre_submission_filter to read the values which were submitted, then perform your logic based on the answers, then update a hidden field in the form.

    Posted 11 years ago on Thursday December 6, 2012 | Permalink