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!
In a previous blog post, I explained how to manually assign values to choice options using if/then statements, like so:
(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, 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!