# Conditional Calculations \[RESOLVED\]

**URL:** <https://community.gravityforms.com/t/conditional-calculations-resolved/5682>\
**Category:** Get Help\
**Tags:** calculations\
**Created:** [August 11, 2020, 11:21pm UTC](https://community.gravityforms.com/t/conditional-calculations-resolved/5682 "2020-08-11T23:21:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Renee\_Bruneau](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@Renee\_Bruneau](https://community.gravityforms.com/u/Renee_Bruneau)\
**Post date:** [August 11, 2020, 11:21pm UTC](https://community.gravityforms.com/t/conditional-calculations-resolved/5682/1 "2020-08-11T23:21:16Z")

</div>

Hoping someone might be able to help.

Need to apply discounts to a field based on values chosen across 5 fields and trying to do so in the most efficient way possible.

Would love to write a calc that can access multiple field values on the form and do the applicable calculation.

For example:  
Trying to set the number field, Product Cost based on the following:

If field A=10 and field B=Yes and field C=Green and field D=45 and field E=Square, then Product cost = (250_10_1.08)+(45\*.33)

However, I’d add several permutations of that calc based on varying values of fields A,B,C,D,E

Is there a fairly simple way to do this within the calculation area of the number field. If so, can you share the base syntax?

Much thanks!

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [August 11, 2020, 11:29pm UTC](https://community.gravityforms.com/t/conditional-calculations-resolved/5682/2 "2020-08-11T23:29:30Z")

</div>

There’s no simple way to do that in Gravity Forms. You would need to have an individual product, configured as a calculation. and show that conditionally based on all those possible choices in the form. One issue with that is that Gravity Forms does not support complex conditions such as “IF this field is SOMETHING AND IF another field is SOMETHING ELSE”. There is a 3rd party plugin to support that conditional logic, but even then, you would be configuring many many products.

One possible alternative if this plugin:

> **[Gravity Forms eCommerce Fields - Gravity Wiz](https://gravitywiz.com/documentation/gravity-forms-ecommerce-fields/)**
>
> Make Gravity Forms more eCommerce-friendly with support for Tax, Discounts, and Subtotal fields plus a bunch of other helpful eCommerce features.

It’s a complex add-on, and I am not sure if that will actually accomplish what you need. However, they have some videos on their site, and a tutorial here:

> **[Gravity Forms eCommerce Tutorial | The Comprehensive Guide - Gravity Wiz](https://gravitywiz.com/gravity-forms-ecommerce-tutorial-the-comprehensive-guide/)**
>
> In this comprehensive guide we will go over how you can use Gravity Forms as an eCommerce solution, instroduce you to a variety of addons that will allow you to amplify your eCommerce store and a number of additional resources for specific eCommerce...

Maybe that will give you some ideas you can work with?

---

<div class="post-metadata">

**Author:** ![david](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/david/32/2517_2.png) [@david](https://community.gravityforms.com/u/david)\
**Post date:** [August 12, 2020, 11:51am UTC](https://community.gravityforms.com/t/conditional-calculations-resolved/5682/3 "2020-08-12T11:51:48Z")

</div>

Could you give more examples of the formulas you would be running and which values in those formulas would be field-based?

---

<div class="post-metadata">

**Author:** ![Renee\_Bruneau](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@Renee\_Bruneau](https://community.gravityforms.com/u/Renee_Bruneau)\
**Post date:** [August 12, 2020, 2:51pm UTC](https://community.gravityforms.com/t/conditional-calculations-resolved/5682/4 "2020-08-12T14:51:35Z")

</div>

Thanks for the help thus far. Looking into the plugin to see if it will work for us.

Here are more details on the calculations:

The user will pick a class which has a specific price. There are 5 class choices.  
The user has been previously assigned a discount code. There are 5 different discount codes.  
The user may choose up to sign up to 3 people up in a single transaction and the discount code applies uniformly to all people.  
Depending on their original discount code, they are offered a further discount if they choose to pay in full vs. make partial payment.  
There is a registration fee for each person for which the discount code does not apply.  
There is a materials fee for each person which varies by class and the discount code conditionally applies (applies for some discount codes, but not others).

So we need to add the following:  
Class \* Discount Code for up to 3 people  
Materials Fee \* Discount Code (conditionally)  
Registration Fee for up to 3 people

Then, apply Supplemental Discount across entire transaction (conditionally).

So in summary, it’s a lot of “if” conditions. I was most recently looking into whether or not we could assign values to each of the conditions such that regardless of which class or discount code applied, you’d still just multiply them together without actually assessing them. Do you know if this is possible?

Most of the conditions are either Radio Buttons or Drop Downs, and have non-numeric choices, but in actuality each has a numeric value that can be assigned to it such that the calculation is constant regardless of their choices. Hoping this is possible as it seems it would be the simplest way of attacking all the permutations.

---

<div class="post-metadata">

**Author:** ![Renee\_Bruneau](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@Renee\_Bruneau](https://community.gravityforms.com/u/Renee_Bruneau)\
**Post date:** [August 12, 2020, 3:08pm UTC](https://community.gravityforms.com/t/conditional-calculations-resolved/5682/5 "2020-08-12T15:08:25Z")

</div>

Disregard the last part of previous post regarding “values”. I thought I had seen it before but was looking in Advanced tab, but now I am easily seeing it in the General tab. I think I’m able to run with this now assuming calcs will use value.

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [August 12, 2020, 3:27pm UTC](https://community.gravityforms.com/t/conditional-calculations-resolved/5682/6 "2020-08-12T15:27:00Z")

</div>

If you need to use a value in a merge tag, for a calculation, you can add the `:value` modifier, like this:

```auto
{My Field Name:23:value}

```

If the field ID was 23, that value modifier will give you the value of the field to work with.

---

<div class="post-metadata">

**Author:** ![Renee\_Bruneau](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@Renee\_Bruneau](https://community.gravityforms.com/u/Renee_Bruneau)\
**Post date:** [August 12, 2020, 5:43pm UTC](https://community.gravityforms.com/t/conditional-calculations-resolved/5682/7 "2020-08-12T17:43:17Z")

</div>

RESOLVED - Thanks everyone for the help. All calcs in with every permutation and working well. Did not need to use an add on plugin.

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [August 12, 2020, 5:50pm UTC](https://community.gravityforms.com/t/conditional-calculations-resolved/5682/8 "2020-08-12T17:50:00Z")

</div>

Closed on August 12, 2020, 5:50pm UTC


