When building a form using Cognito Forms, I am trying to create a discount code field that will accept 2 different codes and apply each with a different discount on the base rate.

I cannot figure out how to calculate the discount code when using more than one discount code.

E.g. : CODE1 = 15% discount; CODE2 = 25% discount. These discounts are applied to a selected REGISTRATIONRATE.

I found this code for the calculation of the discount amount on the Field Setting of Price: = CouponCode = "CODE1" ? -FullWeekendRegistration_Amount*.15 : 0

which works for one couponcode only. What is the syntax to add the 2nd code? i.e. I want to say IF couponcode="CODE1" then apply a 15% discount to the base rate else if couponcode="CODE2" then apply a 25%. discount to the base rate.

  • 1
    I'm afraid it's not clear what Web app you're talking about. It's obviously not IFTTT.
    – ale
    Feb 1, 2015 at 21:09

1 Answer 1


I am a developer for Cognito Forms.

The example you included was from this blog post on three ways to implement discounts in Cognito Forms.

The syntax for the discount calculation would be:

=CouponCode = "CODE1" ? 0.15 : CouponCode = "CODE2" ? 0.25 : 0

The syntax is a bit cryptic (used by JavaScript and other C languages), but generally it is:

[condition] ? [true result] : [false result]

But you can chain them together indefinitely like:

[condition 1] ? [true result 1] : [condition 2] ? [true result 2] : [condition 3] ? [true result 3] : [false result]

The full documentation for calculations can be found on the Cognito Forms help site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.