Assigning Numeric Values to Choice Fields!

Nadia Afshar By Nadia Afshar | March 7, 2017

We’re excited to reveal a new Choice field enhancement: the Assign Values option! Similar to the Assign Prices option, this enhancement gives you the ability to assign numeric values to each option in a Choice field. Whether you want to build a quiz for your students, or screen prospective tenants for your rental property, there are a variety of scenarios in which these values can really come in handy!

Assign Values

Previously, in order to assign values to a Choice field, you had to manually assign the values using if/then statements:

(if HowIsYourCredit = "Good" then 1 else 0)

Now, however, you can simply add that value directly to the choice option; just select Assign Values from your Choice field settings, and enter values for any (or all) of your choice options:

The value can be positive or negative, and can even include decimals.

Calculate Values

Now that you’ve assigned your choice values, you can directly target them in calculations by denoting the Choice field’s name followed by _Value:

=ChoiceField_Value

Based on the choice option selected, the Value attribute will display the corresponding numerical value. For example, if you’re creating a quiz, start by adding a Calculation field to your form (make sure that it’s set to Internal view only). Next, just add up each question’s value to calculate a total score:

=Question1_Value + Question2_Value + Question3_Value

To display the total to your students, insert your Calculation field into your form’s confirmation message:

You could also use an if/then statement to display a specific message depending on the total score:

=if TotalScore = "10" then "Great job!" else ""

Calculate and display scores with assigned values.
Learn More

Nadia Afshar

Nadia Afshar

Nadia, the Technical Writer for Cognito Forms, develops documentation, support content, and how-to videos. No matter your experience – with her help, you'll be able to take full advantage of the product. In her spare time, Nadia enjoys listening to French house, drinking coffee, and talking about herself in third person.

Cognito Forms allows you to easily build powerful forms. Sign Up Now
Blog