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!
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.
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:
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 ""
Have any questions about assigning Choice field values? Feel free to contact us or leave a comment below!
Nadia is the Marketing Coordinator for Cognito Forms. In her spare time, Nadia enjoys listening to French house, drinking iced coffee, and talking about herself in third person.