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 totals based on multiple criteria

  1. longbow
    Member

    Hi, just wondering if someone could help as this is really mangling my head! I've already had a look at these three posts and think I'm almost there but not quite:

    http://www.gravityhelp.com/forums/topic/simple-calculations
    http://www.gravityhelp.com/forums/topic/total-count-of-values
    http://www.gravityhelp.com/forums/topic/adding-values

    So I've got a list of 20 yes/no questions and the radio buttons consist of values yes = 1 and no = 0. You answer all 20 questions either yes/no and dependent on the answers to different questions, depends on the "group" that you fit into. So for instance scoring a minimum of 3 with Q1-Q5 means you're one group. Scoring a minimum of 3 between Q6-Q10 means another group and so on. There are four possible groups that you could fit into.

    And as long as you've scored 3 or more in only ONE category, then you're just in that one group (even if you've scored say 2 in another group and 2 and 0 in the other groups). I've got the totals displaying fine for each section so I can do conditional shizzle based on those values etc.

    However, if you score 3 or more in TWO or more groups, then you don't fit into a, b, c or d but actually group e!

    Now I can't help feeling that displaying a total for group e (when appropriate) should also be relatively straightforward but I don't think it can be done via the normal GF conditional widget logic or calculation functionality (unless you iteratively create more calculation fields that cover all permutations between 2 groups - but this seems messy).

    More likely a function that is then hooked into.

    So, could anyone give a heads up on how this might work? The conditional total for group e would need to update live (i.e. rather than at form submission) and would need to be a field because these answers and values will be being emailed to the participant.

    Any ideas? Thanks.

    Posted 12 years ago on Tuesday November 20, 2012 | Permalink
  2. I don't think it can be done with the calculations which are available. And because you want to do it live, on the front end, you're going to have to do it with jQuery or JavaScript, which is how the calculations work now. I have not seen any examples of anyone doing this sort of calculation before form submission yet.

    Posted 12 years ago on Wednesday November 21, 2012 | Permalink
  3. longbow
    Member

    Yeah, don't worry I've figured it out now using gform_pre_render and putting the final calculation on the second page of the multipart form (so everything gets checked when you click the "Next" button). This seems to work fine for what I need.

    Posted 12 years ago on Wednesday November 21, 2012 | Permalink